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?
Flex Viewstack's children, if you can't see them, do they exist?
11.8k Views Asked by mjard At
3
There are 3 best solutions below
0

Yeah, I had this same problem myself while working on an application with a PureMVC structure. I was unable to create mediators for the subcomponents of a ViewStack because they were constructed lazily by the Flex framework.
Here's where I eventually found my solution:
0

Found the relevant documentation here. Seems like that'd be something you'd make a note of on the container docs.
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
: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.