Hi Jason,

This syntax looks correct...

> currentState = targetComp.dataProvider[event.index].data;

... as long as targetComp.dataProvider[event.index].data gives the
name of the state that you want. I noticed that you output this to a
text field, so I assume that it's correct. So it's the usual
check-for-empty-spaces-and-stuff-like-that. 

Another method is to use a TabNavigator in place of a Tab Bar, and use
custom components for the individual tabs. Something like this:

<mx:TabNavigator>
<jx:CustomComponent1 label="First Tab" />
<jx:CustomComponent2 label="Second Tab" />
<jx:CustomComponent3 label="Third Tab" />
</mx:TabNavigator>

Or you could re-use the same component with different data for each tab:

<mx:TabNavigator>
<jx:CustomComponent1 label="First Tab"
dataObject="{myArrayCollection.getItemAt(0)}" />
<jx:CustomComponent1 label="Second Tab"
dataObject="{myArrayCollection.getItemAt(1)}" />
<jx:CustomComponent1 label="Third Tab"
dataObject="{myArrayCollection.getItemAt(2)}" />
</mx:TabNavigator>

Either way, a nice thing about using the TabNavigator approach is that
the Flash player doesn't load the contents of a tab into memory until
the user clicks on the tab. This helps the app load faster, and saves
client resources generally. I'm not sure if this also applies to states. 

-Jim



--- In flexcoders@yahoogroups.com, "Merrill, Jason"
<[EMAIL PROTECTED]> wrote:
>
> Thanks everyone for your help and ideas.  Very useful.  I have something
> working now, but not with a custom component, though Jim I will try out
> your ideas there.
>  
> My next architecture question has to do with states and navigation.  I
> have a TabBar I am trying to use to navigate between different states -
> different pages in my application which all look very different except
> the navigation piece. Is this the best way to handle switching between
> different screens?  I was able to render the TabBar based on my data
> bindings without a problem, and I can register the event that the tab
> was clicked, but i was unable to get it to change states.  I tried:
>  
>    private function tabClick(event:ItemClickEvent):void {
>              var targetComp:TabBar = TabBar(event.currentTarget);
>              forClick.text="label is: " + event.label + " index is: " +
> event.index + " capital is: " +
> targetComp.dataProvider[event.index].data;
>              currentState = targetComp.dataProvider[event.index].data;
>          }   
>  
> Where .data is the name of the state I want to change to.  What is the
> proper approach?  Thanks!
>  
> 
> Jason Merrill 
> Bank of America
> Learning & Organizational Effectiveness
>


Reply via email to