PDA

View Full Version : Help With Accordion


smilie
03-29-2010, 08:29 AM
Hey guys,

I have a bit of an Issue with using an accordion. I'm new to Flex so sorry if this is a bit of a noob question.

I have an accordion declared as following:

<mx:Accordion width="500" height="200" right="10" id="accordion" visible="false" backgroundColor="purple"
borderColor="0xc7A317" borderThickness="2" color="0xc7A317" textDecoration="Bold"
x="605" y="250" >
<mx:Canvas id="can1" label="Accordion Pane 1" width="100%" height="100%" verticalScrollPolicy="off">

<mx:TextArea id="TA" x="10" y="10" width="90%" height="138" backgroundColor="purple"
borderColor="0xc7A317"/>

</mx:Canvas>
<mx:Canvas id="can2" label="pane 2" width="100%" height="100%" verticalScrollPolicy="off">
<mx:TextArea id="TA2" x="10" y="10" width="90%" height="138" backgroundColor="purple"
borderColor="0xc7A317" />
</mx:Canvas>
<mx:Canvas id="can3" label="pane 2" width="100%" height="100%" verticalScrollPolicy="off">
<mx:TextArea id="TA3" x="10" y="10" width="90%" height="138" backgroundColor="purple"
borderColor="0xc7A317" />
</mx:Canvas>
</mx:Accordion>

As you can see there are 3 canvases in the accordion button. My problem is that while I find I can access the first canvas in my actionscript code, I am unable to access the other two (can2, can3). If anyone can inform me as to how I can go about that, it would be very helpful. Thanks.

yul57
03-29-2010, 09:59 AM
Why do you use the "visible" property in your Accordion. To my mind, you should remove it

Yui
03-29-2010, 12:55 PM
the accordion is one of the components that only load what they "need" to, i'm saying that only the first canvas is created when you first load it, only after you click on the accordion tabs, the content of the other canvases is loaded.

you can force the accordion to load everything when it's created, using the creationPolicy="all" property (in the <accordion> tag).

however, depending how much information all the canvases contain, it might not be wise to load everything from the start (i.e., if the user never accesses one of the tabs, it's kind of useless to waste time loading its content).

maybe you can tell us why are you trying to access the content of a tab that is not loaded yet. you should do that stuff once the tab is clicked.

smilie
03-31-2010, 04:31 AM
Hey, this was exactly what I needed! Thanks!

"maybe you can tell us why are you trying to access the content of a tab that is not loaded yet. you should do that stuff once the tab is clicked."

Well, I have a map and I was querying it at the start of my program and attempting to store some of the data in the accordion button tab's text fields, to avoid having to store it in an extra variable. I didn't know that the fields in the tabs didn't load till it was clicked so I wasn't sure why this wasn't working.

I've corrected it by storing the queried info in variables and assigning them to the tabs text field only after it is loaded.

Thanks!