0

我有一个 Flex TabbedViewNavigatorApplication

有两个自定义导航器:

<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>

现在我想以编程方式,根据我的应用程序中的一些事件在导航器之间切换。

我在 StackOverflow 上发现的唯一问题是这个Switch between Flex Tabbed ViewNavigators

但该解决方案仅适用于您在 Main.mxml 中工作,或者使用navigator.selectedIndex = 1;(或在我的情况下tabbedNavigator.selectedIndex = 1;)或使用TabbedViewNavigator(navigator.parentNavigator).selectedIndex = 1;

但我不知道如何在我的应用程序中访问导航器,而不是在 Main.mxml

4

1 回答 1

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;
        }
于 2014-05-21T06:28:23.393 回答