By default, TabNavigator, as well as most of the other navigation
components, uses "deferred instantiation".  This means that the children
of a view are not created until a user navigates to that view.  The
purpose is to shorten the time it takes for the application/component to
display for the first time.  The time to render is taken when the child
is actually viewed.

 

The correct fix depends on what you are trying to do.  Best practice is
to use an event on the view, such as creationComplete and show, to kick
of any functionality that needs to work with the children.

 

What are you doing in your dom traversal?

 

A dirty fix for this is available, but defeats the purpose of deferred
instantiation, and if you get in the habit of using it it will come back
to haunt you.  That fix is to set creationPolicy="all" on the
TabNavigator.  But don't do it.

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of timgerr
Sent: Wednesday, November 12, 2008 3:18 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Traverse through a TabNavigator

 

Hello all, I have a TabNavigator that contains 2 forms:
<mx:TabNavigator x="196" y="160" width="200" height="200" id="TopTab">
<mx:Form id="FormOne" label="User">
<mx:FormItem label="First Name">
<mx:TextInput id="fname"/>
</mx:FormItem>
<mx:FormItem label="Last Name">
<mx:TextInput id="lname"/>
</mx:FormItem>
</mx:Form>

<mx:Form id="FormTwo" label="Address">
<mx:FormItem label="Address">
<mx:TextInput id="address"/>
</mx:FormItem>
<mx:FormItem label="Zip Code">
<mx:TextInput id="zip"/>
</mx:FormItem>
</mx:Form>
</mx:TabNavigator>

and I wrote this script to traverse a Form:
public function Frm(f:Form):void
{
var a:Array = f.getChildren();
for(var i:int = 0; i < a.length; i++){
this.FrmI(a[i]);
} 
}

public function FrmI(f:FormItem):void
{
var a:Array = f.getChildren();
for(var i:int = 0; i < a.length; i++){
trace(a[i].id);
}
}

so the script will take a form object, then see how many childreen it
has then it will send the formitems to FrmI. Frmi will get me the name
of the child objects and that is all. So the problem is when I run
init()
public function init():void
{
Frm(FormOne);
Frm(FormTwo);
}
I get this in return:
fname
lname

If I just run the 2nd form like this:
public function init():void
{ 
Frm(FormTwo);
}

Nothing is displayed. I think this has to do with TabNavigator. It
looks to only get information from the tab that is on the top. Is
that correct, and what do I have to do in order to get all the
information ?

Thanks,
timgerr

 

Reply via email to