|
<rant> Several times a week someone complains
that they can't seem to set data into controls on the second, third, etc. pane
of a ViewStack, Accordion, or TabNavigator because these controls don't get
created until the user navigates to the pane they're on. Inevitably there are multiple replies "solving"
this problem by setting creationPolicy="all". Inevitably I reply that
Adobe doesn't recommend doing this because it defeats the entire purpose of the
deferred instantiation feature, which is to minimize startup time by not
creating visual components until they need to be seen. A much better technique is to use event
handlers to get the appropriate data into the controls after they get created.
For example, you can use the 'initialize' event on each pane, which won't get
dispatched until after that pane's controls exist. <mx:Accordion> <mx:VBox
initialize="textInput1.text='Hello'"> <mx:TextInput
id="textInput1"/> </mx:VBox> <mx:VBox
initialize="textInput2.text='World'"> <mx:TextInput
id="textInput2"/> </mx:VBox> </mx:Accordion> Using databinding is another good technique.
The bindings will occur after the controls get created. I've never seen a case where it is
necessary to push data into the controls before they exist. If you must put the
data somewhere in the meantime, store it in data vars, which have none of the
startup cost of a visual component, and then move it into the controls after
they get created. </rant> - Gordon, the Flex framework engineer who
designed and implemented the deferred instantiation feature, so listen to me on
this one! -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
SPONSORED LINKS
Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required) Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe __,_._,___ |
- [flexcoders] Accordion initialization problem Rick Root
- [flexcoders] Re: Accordion initialization problem joshuajnoble
- [flexcoders] Re: Accordion initialization proble... Michael Labriola
- Re: [flexcoders] Accordion initialization problem Adam Dorritie
- [flexcoders] JUST SAY NO to creationPolicy="... Gordon Smith
- [flexcoders] Re: JUST SAY NO to creationPoli... joshuajnoble
- RE: [flexcoders] Re: JUST SAY NO to crea... Gordon Smith
- [flexcoders] Re: JUST SAY NO to creationPoli... Michael Labriola
- Re: [flexcoders] JUST SAY NO to creationPoli... John Kirby
- RE: [flexcoders] JUST SAY NO to creation... Gordon Smith
- Re: [flexcoders] JUST SAY NO to cre... John Kirby
- RE: [flexcoders] JUST SAY NO to... Gordon Smith
- Re: [flexcoders] JUST SAY N... John Kirby
- Re: [flexcoders] JUST SAY N... greg h
- Re: [flexcoders] JUST SAY N... John Kirby

