Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6873163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:01:35+00:00 2026-05-27T04:01:35+00:00

I am working with a flex project with a main mxml file and two

  • 0

I am working with a flex project with a main mxml file and two actionscript classes that draw graphics. From reading tons of articles and posts I discovered that they must extend UIComponent, which they do. The first actionscript class draws the image fine. The first class then makes the call to create a new object. The second object does not display. In the pure actionscript version I had to pass the stage as a reference for the second class to draw.

I also found a similar question here at stackoverflow:
UIComponent extended class isn't showing UIComponent extended class. But I was not sure how to apply it to my example.

Which, if any UIComponent methods should be overrided for the second object to display? How specifically should I implement them in this example?

If there is a better or simpler answer to this problem, that is also appreciated. This is a simplified example of a problem I’m having with a more complex project.

// First class "Ball" draws a circle successfully then creates a second object "MyRect" 

        package dr {
        import flash.display.*;
        import flash.display.Sprite;

        import mx.core.*;

        public class Ball extends UIComponent {
            public function Ball()
            {
                var vCircle:Sprite = new Sprite();
                vCircle.graphics.beginFill(0xff0000);
                vCircle.graphics.drawCircle(100, 150, 40);
                vCircle.graphics.endFill();
                addChild(vCircle);

                var rect:MyRect = new MyRect();
            }   
        }
    }



    // Second class "MyRect" (does not display)

    package dr {
    import flash.display.*;
    import flash.display.Sprite;
    import flash.events.*;
    import flash.geom.*;

    import mx.core.*;

    public class MyRect extends UIComponent
    {
        public function MyRect()
        {   

            var vRect:Sprite = new Sprite();
            vRect.graphics.beginFill(0x0000ff, 1);
            vRect.graphics.drawRect(300, 150, 150, 75);
            addChild(vRect);

            //var ui:UIComponent = new UIComponent();
            //addChild(ui);
            //ui.addChild(vRect);
            //UpdateDisplayList();  
        }

    }   
}

    //Here is the MXML main file:

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   xmlns:dr="dr.*"
                   minWidth="955" minHeight="600">
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <mx:Panel id="myPanel" width="700" height="600" paddingLeft="10" paddingTop="10">   
                <dr:Ball></dr:Ball>
        </mx:Panel>
    </s:Application>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:01:36+00:00Added an answer on May 27, 2026 at 4:01 am

    In your Ball class, you instantiate a new MyRect class; however, you don’t add it to the stage:

    var rect:MyRect = new MyRect();
    addChild(rect);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a project that uses ActionScript 3.0 with Flex SDKs. The project
I am working on a project in Android now that involves parsing XML from
We're working on a Flash CS4 project where the main .fla file has ballooned
I'm working on a flex project, and have a datagrid that I'd like the
I'm working on a little project in Flex that's an application to upload images
We are working on a project that uses Flex and rails with WebORB .
I'm working on a project where I need to make a Flex application that
I'm looking to have a couple of plugins in a Flex project I'm working
I'm working with flex, but actionscript ideas are just as good. The flex <s:Application>
I'm working on a website built in Flex, but the SWF file after compiling

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.