tags:

views:

344

answers:

2

When I try to access the hidden TABs of my tab navigator control in action script, it returns a null error. But it works OK if I just activate the control in the user interface once. Obviously the control is not created until I use it. How do I make all the tabs automatically created by default ?

+8  A: 
<mx:TabNavigator creationPolicy="all"/>

That should do it. Deferred instanciation is a feature, but sometimes it is a hassle.

Joel Hooks
Thanks. That worked !
captonssj
Ya, that is always kind of a weird "WTF". You should go ahead and accept the answer if it worked. ;)
Joel Hooks
A: 

The Flex framework is optimizing creation be default (creationPolicy="auto") so if you have a configuration dialog with a lot of tabs, for example, and the most useful tab is the first one, your application does not spend time and memory initializing the tabs that the user never sees.

This makes a lot of difference when dialogs like this never release, and is a good default to go with.

One thing to look at is using a private variable in your dialog/form instead of pushing the data to the control on the hidden page. This style treats the whole form as if it were a component, which it sort of is. To repeat: the MXML form/dialog/canvas is a class, and it can have data and methods in addition to containing other components.

Cheers

Richard Haven