Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex Viewstack's children, if you can't see them, do they exist?

I seem to be running into an issue (Cannot access a property or method of a null object reference) binding events in actionscript to a viewstack layer not currently showing. Are those objects not created until that layer is visible for the first time? I remember something about a creation policy, if this is the case, can I force it to create those children before that layer is viewed?

like image 360
mjard Avatar asked Dec 03 '22 08:12

mjard


1 Answers

Yes, that's right -- ViewStack children are created only when needed by default ("deferred instantiation" is a phrase you'll hear thrown around in this context). If instead you want to instruct Flex to create all of the ViewStack container's children up front, consider using the creationPolicy property common to all mx.core.Containers:

A creationPolicy of ContainerCreationPolicy.ALL means that the navigator containers immediately create deeper descendants for each child, rather than waiting until that child is selected.

<mx:ViewStack id="myStack" creationPolicy="all" />

It's a bit slower on startup, because you're creating a bunch of child components you might not need yet, but as long as you keep that tradeoff in mind, it may come in handy sometime.

like image 62
Christian Nunciato Avatar answered Dec 20 '22 10:12

Christian Nunciato