In small test application I have the follow object… stack
The “Main.mxml” loads the EntryClass.as -> “class EntryClass” (that doesn’t extends anything) -> “public static function Main()”.
This EntryClass.Main() function is doing the follow:
var mxmlApp:Application = Application(Application.application);
var mainAppClass:MainAppClass=new MainAppClass();
So the mainAppClass is loaded.
Now the MainAppClass extends the UIComponent and in its constructor does this:
var buttonFromMainClass:Button=new Button();
to add it to stage I call
and here is the problem! The button is not appeared on the stage, but using this code:
the button is added to the stage and it is visible.
Why the button is not added to the stage with the simple addChild? Where am I wrong?
Something that might be help, in EntryClass.Main() if I create a button and add it with the mxmlApp.addChild, the button is added and appeared on the stage normally, so there is no problem with the use of mxmlApp.addChild.
If MainAppClass hasn't implemented all of the lifecycle methods, it might be reporting 0 size and simply is collapsed on itself. See measure() and updateDisplayList() and doc on creating custom components.
Flex SDK Developer
Adobe Systems Inc.
Hi... somebody helped me to findout that... the button hasn’t (at all) width and height!
What is the difference between the
In the adding process???
Sure is that the Application.addChild() makes correction when the width and height is 0.