2013-03-27 56 views
0
我使用一個標籤導航

我的主要應用程序MXML,我可以在任何地方通過下面的代碼訪問標籤導航儀應用程序..訪問標籤導航及其子從一個子元素

mx.core.FlexGlobals。 topLevelApplication.menuOption.selectedIndex = 0;

現在我的問題是我在事務UI中使用了一個切換按鈕欄,這是一個選項卡導航器的子元素,如何訪問像上面提到的代碼那樣的元素?

我的主MXML標籤導航::

<mx:TabNavigator left="10" top="20" bottom="10" right="10" id="menuOption" > 

    <ui1:homeUI label="Home" width="100%" height="100%" backgroundColor="#373737" chromeColor="#181818" contentBackgroundColor="#181818" color="#FDFDFD" /> 

    <ui1:transactionUI label="Transaction" width="100%" height="100%" backgroundColor="#373737" />  

     <ui1:calanderUI label="Employee service" width="100%" height="100%" horizontalCenter="0" backgroundColor="#373737" chromeColor="#181818" contentBackgroundColor="#181818" color="#FDFDFD" /> 
     <ui1:ManagementUI label="Management" width="100%" height="100%" backgroundColor="#373737" chromeColor="#181818" contentBackgroundColor="#181818" color="#FDFDFD" /> 
     <ui1:reportUI label="Reports" width="100%" height="100%" backgroundColor="#373737" chromeColor="#181818" contentBackgroundColor="#181818" color="#FDFDFD" /> 

     <ui1:admin label="Admin" width="100%" height="100%" backgroundColor="#373737" chromeColor="#181818" contentBackgroundColor="#181818" color="#FDFDFD" /> 

    </mx:TabNavigator> 

在我的主應用程序MXML我使用的標籤導航,我可以用下面的代碼在任何地方訪問該選項卡瀏覽器在應用..

mx.core.FlexGlobals.topLevelApplication.menuOption.selectedIndex = 0;

現在我的問題是我在事務UI中使用了一個切換按鈕欄,這是一個選項卡導航器的子元素,如何訪問像上面提到的代碼那樣的元素?

我的主MXML標籤導航::

<ui1:homeUI label="Home" width="100%" height="100%" backgroundColor="#373737" chromeColor="#181818" contentBackgroundColor="#181818" color="#FDFDFD" /> 

<ui1:transactionUI label="Transaction" width="100%" height="100%" backgroundColor="#373737" />  

    <ui1:calanderUI label="Employee service" width="100%" height="100%" horizontalCenter="0" backgroundColor="#373737" chromeColor="#181818" contentBackgroundColor="#181818" color="#FDFDFD" /> 
    <ui1:ManagementUI label="Management" width="100%" height="100%" backgroundColor="#373737" chromeColor="#181818" contentBackgroundColor="#181818" color="#FDFDFD" /> 
    <ui1:reportUI label="Reports" width="100%" height="100%" backgroundColor="#373737" chromeColor="#181818" contentBackgroundColor="#181818" color="#FDFDFD" /> 

    <ui1:admin label="Admin" width="100%" height="100%" backgroundColor="#373737" chromeColor="#181818" contentBackgroundColor="#181818" color="#FDFDFD" /> 

</mx:TabNavigator> 

* 內transactionUI我的肘杆:: *

<s:NavigatorContent xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%" 
       xmlns:ui="com.colan.*" xmlns:ui1="com.colan.ui.*" 
       backgroundColor="#373737" chromeColor="#181818" 
       contentBackgroundColor="#181818" color="#FDFDFD"> 
<fx:Declarations> 
    <!-- Place non-visual elements (e.g., services, value objects) here --> 
</fx:Declarations> 
<fx:Script> 
    <![CDATA[ 

     import mx.collections.*; 
     import mx.core.*; 
    ]]> 
</fx:Script> 
<mx:VBox horizontalAlign="center" verticalAlign="middle" width="100%" height="100%"> 

    <mx:HBox horizontalAlign="center" verticalAlign="middle" width="100%" height="15%" > 

     <mx:ToggleButtonBar id="toggleButtonBar" 
          dataProvider="{viewStack}"  
          selectedButtonTextStyleName="mySelectedButtonTextStyleName" 
          /> 


    </mx:HBox> 
    <mx:HBox horizontalAlign="center" verticalAlign="middle" width="100%" height="85%" > 


     <mx:ViewStack id="viewStack"     
         visible="{toggleButtonBar.selectedIndex > -1}" width="100%" height="100%" > 

      <ui1:transaction label="Transaction"/> 
      <ui1:addClient label="Add Client"/> 
      <ui1:invoice label="Make invoice"/> 
      <ui1:workCatalogue label="Work catalogue"/> 
      <ui1:productCataloge label="Products Categories"/> 

      <ui1:suppliers label="Offers"/> 
      <ui1:calendarPlanUI label="Calendar"/> 


     </mx:ViewStack> 
    </mx:HBox> 
</mx:VBox> 

請諮詢我...

+1

這是否有幫助:http://www.flextras.com/blog/index.cfm/2013/2/1/How-does-one-Flex-Component-talk-to-another-Flex-Component – JeffryHouser 2013-03-27 18:24:58

回答

0

( (mx.core.FlexGlobals.topLevelApplication.menuOption).getChildAt(1)as transactionUI).toggleButtonBar

儘管這很粗糙,但可以幫助您開始。沒有測試過。