On 8/27/16, 9:26 AM, "CodeGirl" <[email protected]> wrote:

>I have an options panel.
>
>I have a panel which I display an image with the options from the options
>panel.
>
>The Options panel has a   Tab Navigator for different categories of
>Options.
>
>In the parent of both panels, I have my event listeners for all my
>options.
>
>The problem is that my event listeners for the Navigator Tabs which are
>not
>selected keep giving me a null reference error.  Since the tab is not
>selected yet, the MXML Component has not yet been created hence the null
>reference error.  
>
>How do I get around this?
>

Again, I'm not sure I fully grasped the problem from this description, but
the words "Tab Navigator" and "null" in the same email sounds like you
have a "push-down" vs "pull-down" scenario.  For performance reasons,
things like Tab Navigator try not to instantiate all of their children at
startup.  Thus, starting from the Application, children of the Application
get created, then their children, and so forth until you hit a deferred
instantiation container.  Then those children are only created
"just-in-time".  Otherwise, in really complex scenarios where
TabNavigators have children that contain TabNavigators, lots of component
would get created but potentially never seen and that delays startup time
significantly.

However, the temptation is to write our code to "push down" data to the
children.  Unfortunately, that doesn't work if the children are not yet
created.  So the answer is to have the children "pull down" their data.
You can use data binding, or creationComplete handlers on the children.
This decentralizes your code: the big script block has to get broken into
little bits of code scattered throughout the MXML components, but IMO,
that is actually better encapsulation, and allows deferred instantiation
to maximize performance.

HTH,
-Alex

Reply via email to