Actionscript 3 从子元素访问选项卡导航器及其子元素
我的主应用程序mxml我使用的是选项卡导航器,我可以通过以下代码访问应用程序中的任何位置的选项卡导航器Actionscript 3 从子元素访问选项卡导航器及其子元素,actionscript-3,apache-flex,air,flex4,Actionscript 3,Apache Flex,Air,Flex4,我的主应用程序mxml我使用的是选项卡导航器,我可以通过以下代码访问应用程序中的任何位置的选项卡导航器 mx.core.FlexGlobals.topLevelApplication.menuOption.selectedIndex=0 现在我的问题是我在transactionUI中使用了一个切换按钮栏,它是tab navigator的子元素,我如何像上面提到的代码一样访问该元素 我的主mxml选项卡导航器:: <mx:TabNavigator left="10" top="20" b
mx.core.FlexGlobals.topLevelApplication.menuOption.selectedIndex=0 现在我的问题是我在transactionUI中使用了一个切换按钮栏,它是tab navigator的子元素,我如何像上面提到的代码一样访问该元素 我的主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 现在我的问题是我在transactionUI中使用了一个切换按钮栏,它是tab navigator的子元素,我如何像上面提到的代码一样访问该元素 我的主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>
请告诉我…((mx.core.FlexGlobals.topLevelApplication.menuOption)。getChildAt(1)作为transactionUI)。切换按钮栏
虽然这很粗糙,但有助于你继续前进。尚未测试。这是否有帮助: