<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
Software development tool Software development Software development services
Home design software Software development company

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

__,_._,___

Reply via email to