问题描述
我正在开发一个带有三个选项卡(ViewNavigator 元素)的 Flex TabbedViewNavigatorApplication
.我想根据用户操作(通过 ActionScript 代码)从一个 ViewNavigator 切换到另一个.
I am working on a Flex TabbedViewNavigatorApplication
with three tabs (ViewNavigator elements). I would like to switch from one ViewNavigator to another based upon a user action (via ActionScript code).
我知道在视图之间切换使用 pushView
和 popView
,但我正在使用 ViewNavigators,我的搜索没有发现任何有用的东西.
I know that switching between Views uses pushView
and popView
, but I'm working with ViewNavigators, and my searching revealed nothing useful.
我正在尝试在事件发生时从 Tab2 切换到 Tab1.在这种情况下,Tab2 包含一个列表,当用户进行选择时,我想跳回 Tab1.
I'm trying to switch from Tab2 to Tab1 when an event occurs. In this case, Tab2 contains a list, and when the user makes a selection, I want to jump back to Tab1.
<s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
creationComplete="onAppReady(event)">
<s:ViewNavigator label="Tab1" width="100%" height="100%" firstView="views.TabOneView"/>
<s:ViewNavigator label="Tab2" width="100%" height="100%" firstView="views.TabTwoView"/>
<s:ViewNavigator label="Tab3" width="100%" height="100%" firstView="views.TabThreeView"/>
</s:TabbedViewNavigatorApplication>
感谢您的帮助!
推荐答案
这个类奇怪地没有记录.我自己没有尝试过,但是从网上搜索,,这与网络的其余部分的行为相吻合.
您需要做的是将一个事件冒泡到 TabbedViewNavigatorApplication
,然后将 selectedIndex
属性更改为您需要更改到的任何选项卡.例如:
<s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
creationComplete="onCreationComplete()">
<fx:Script>
<![CDATA[
private function onCreationComplete():void
{
this.addEventListener('someEvent', someHandler);
}
private function someHandler(e:Event):void
{
this.selectedIndex = 0; // or whatever index you want.
}
]]>
</fx:Script>
<s:ViewNavigator label="Tab1" width="100%" height="100%" firstView="views.TabOneView"/>
<s:ViewNavigator label="Tab2" width="100%" height="100%" firstView="views.TabTwoView"/>
<s:ViewNavigator label="Tab3" width="100%" height="100%" firstView="views.TabThreeView"/>
</s:TabbedViewNavigatorApplication>
你只需要从你的孩子内部发送一个冒泡事件.您可以创建一个自定义事件来保存有关要切换到哪个选项卡的数据.
这篇关于在 Flex 选项卡式 ViewNavigators 之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!