2014-05-21 14 views
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> 

現在我想以編程方式的基礎上,我的應用程序裏面的一些活動,航海家之間切換。

在計算器上唯一的問題,我發現這是Switch between Flex Tabbed ViewNavigators

,但如果你是你的Main.mxml, 內工作的解決方案只適用要麼是使用navigator.selectedIndex = 1;(或在我的情況tabbedNavigator.selectedIndex = 1;)或使用TabbedViewNavigator(navigator.parentNavigator).selectedIndex = 1;

,但我不知道如何訪問導航我的應用程序裏,而不是在Main.mxml

回答

0

,你將不得不使用一個事件,創建從事件擴展這樣的NavigationEvent:

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

然後將事件偵聽器添加到要更改選項卡的組件中。

COMPONENENT.addEventListener(NavigationEvent.GO_TO_DESTINATION, handleResult); 

然後在handleResult方法中切換視圖。

private function goto(event:NavigationEvent):void{ 
      vs.selectedIndex = event.destIndex; 
     }