Great response, thank you.

Gordon Smith wrote:
> You need to attach the Bob instance to the display list before accessing
> its children. This works:
>
>     public function someFunc():void
>     {
>         var b:Bob = new Bob();
>         addChild(b);
>         trace(b.test1.text);
>     }
>
> A UIComponent constructor creates a new instance but doesn't initialize
> it. After executing
>
>     var b:Bob = new Bob();
>
> a Bob instance exists, but it has parent and no children. As soon as you
> attach a new instance to a parent, it then creates its children, and
> when they are attached they create their children, etc. In this way the
> tree grows downward recursively.
>
> One reason we designed it this way is so that between the 'new' and the
> addChild(), you can set properties and styles on the instance which then
> affect which children get created.
>
> For example, suppose you had a Clock component with had two modes,
> analog and digital, which require different children to display. Then
> you could write
>
>     var clock:Clock = new Clock();
>     clock.mode = "digital";
>     addChild(clock);
>
> and then the hands and the 12 TextFields to display the hours around the
> analog clock wouldn't need to be created; you could delay creating them
> until you set clock.mode = "analog".
>
> - Gordon
>
>
> -----Original Message-----
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of Trey Long
> Sent: Thursday, January 26, 2006 9:35 AM
> To: [email protected]
> Subject: [flexcoders] MXML mixed with AS is null
>
> This problem seems obvious, but I didn't get any hits when I searched
> so...
>
> I have an MXML application, A.mxml;
> and an MXML component C.mxml.
>
> There seems to be an initialization problem when I attempt to create 
> that MXML component C from within a <mx:script> tag in application A. It
>
> seems that the label in component C, test1, isn't initialized at that 
> point.
>
> I know this is hard to follow, but if anyone else thinks they know what 
> I am talking about please let me know.
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml"; xmlns="*"
> xmlns:local="package1.*" creationComplete="someFunc();">
>       
>       <mx:Script>
>               <![CDATA[
>                       import flash.util.trace;
>
>                       public function someFunc() {
>                               var b:Bob = new Bob();
>                               //trace(b.test1.text);
>                       }
>
>               ]]>
>       </mx:Script>
> </mx:Application>
>
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Canvas xmlns:mx="http://www.macromedia.com/2005/mxml"; xmlns="*">
>       <mx:Label id="test1" text="TEST STRING" />
> </mx:Canvas>
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com 
> Yahoo! Groups Links
>
>
>
>  
>
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
> Yahoo! Groups Links
>
>
>
>  
>
>
>
>   


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to