0

I have a Flex TabbedViewNavigatorApplication

With two custom navigators:

<s:navigators>
    <homepagenavigator:HomePageNavigatorView label="Home" id="homePageNavigator" width="100%" height="100%" />
    <categorylistpagenavigator:CategoryListPageNavigatorView label="List of Categories" id="categoryListPageNavigatorView" width="100%" height="100%" />
</s:navigators>

Now I want to programmatically, based on some events inside my app to switch between navigators.

The only question on StackOverflow I found is this Switch between Flex Tabbed ViewNavigators

but the solution is only applicable if you are working inside your Main.mxml, which is either to use navigator.selectedIndex = 1; (or in my case tabbedNavigator.selectedIndex = 1;) or to use TabbedViewNavigator(navigator.parentNavigator).selectedIndex = 1;

but I have no idea how to access navigator inside my app, not in Main.mxml

Community
  • 1
  • 1
inside
  • 3,047
  • 10
  • 49
  • 75

1 Answers1

0

you will have to use an Event, create a NavigationEvent that extends from event like this:

  public class NavigationEvent extends Event
{
    public static const GO_TO_DESTINATION:String = "goToDestination";

    private var _destIndex:Number;
    private var _param:Object;

    public function NavigationEvent(type:String, destIndex:Number)
    {
        super(type, true);
        this._destIndex = destIndex;
    }

And then add the event listener to the component from where you want to change the tab.

COMPONENENT.addEventListener(NavigationEvent.GO_TO_DESTINATION, handleResult);

And then in the handleResult method switch the view.

 private function goto(event:NavigationEvent):void{
            vs.selectedIndex = event.destIndex;
        }
Juanpe
  • 446
  • 5
  • 16