In flex, children are generally not created until they are actually
needed, which generally translates to: when they are displayed on the
screen. This keeps startup time and memory use down as, on average,
most users do not navigate to every corner of an app.
As suggested, you could set the creationPolicy to all, which would
cause all of the children to be created in that container on startup,
altough your app will startup slightly slower.
Understanding the creation order, combined with some testing, for example:
if ( foo ) {
Alert.show(foo.text, 'test', Alert.OK);
}
will get you through without changing the creationPolicy.
--Mike
--- In [email protected], "joshuajnoble" <[EMAIL PROTECTED]> wrote:
>
>
> You're right. The children aren't being created until they're added to
> the display list. Set your creationPolicy on the Accordion to 'all' to
> create them all as soon as the accordion is created.
>
> --- In [email protected], Rick Root <rick.root@> wrote:
> >
> > I'm building an application with an accordion pane, and I'm having
> > problems accessing objects declared within a child panel.
> >
> > For example, look at the code I've attached to the end of this
email...
> >
> > When you click any of the buttons, you get the following error:
> >
> > TypeError: Error #1009: Cannot access a property or method of a null
> > object reference.
> > at testProject/::toggleAccordion()
> > at testProject/___Button1_click()
> >
> >
> > ONLY AFTER VIEWING the second accordion pane does this go away.
> >
> > It's as if the children of the accordion pane aren't initialized
until
> > they are displayed.
> >
> > What's up with that?
> >
> > Here's the sample code:
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
> layout="absolute">
> > <mx:Script>
> > <![CDATA[
> > import mx.controls.Alert;
> > private function toggleAccordion(idx:int)
> > {
> > acdMain.selectedIndex = idx-1;
> > Alert.show(foo.text, 'test', Alert.OK);
> > }
> > ]]>
> > </mx:Script>
> > <mx:Accordion left="10" right="10" top="40" bottom="10" id="acdMain">
> > <mx:Canvas label="Pane 1" width="100%" height="100%">
> > </mx:Canvas>
> > <mx:Canvas label="Pane 2" width="100%" height="100%">
> > <mx:Label id="foo" text="foo"/>
> > </mx:Canvas>
> > <mx:Canvas label="Pane 3" width="100%" height="100%">
> > </mx:Canvas>
> > </mx:Accordion>
> > <mx:Button x="10" y="10" label="Button 1"
click="toggleAccordion(1);"/>
> > <mx:Button x="83" y="10" label="Button 2"
click="toggleAccordion(2);"/>
> > <mx:Button x="156" y="10" label="Button 3"
> click="toggleAccordion(3);"/>
> > </mx:Application>
> >
> > rick
> >
>
--
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/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> 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/