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/