Tuesday, July 15, 2008

Flex Actionscript 3.0 Missing DisplayObject Children

So you have a component like


Awesome.mxml

<mx:Canvas ....>
<mx:Vbox id="avbox" />
</mx:Canvas>



if you try to create your object with as3 like:



var awesome:Awesome = new Awesome();



you'll see that



trace(awesome.avbox); //NULL



gives you null. Thats because your component's children are created using deferred instantiation. If you want to force the component to create its children do:


awesome.initialize();


now when you try:


trace(awesome.avbox); //NOT NULL


there will actually be something there :)

No comments: