Flex的选项卡式ViewNavigators之间切换 [英] Switch between Flex Tabbed ViewNavigators
问题描述
我工作的一个Flex TabbedViewNavigatorApplication
有三个选项卡(ViewNavigator的元素)。我想切换从一个ViewNavigator的另一个基于用户行为(通过ActionScript code)。
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>
感谢您的帮助!
Thanks for your help!
推荐答案
这个类是奇怪无证。我还没试过此我自己,但是从网上搜索,<一个href="http://help.adobe.com/en_US/flex/mobileapps/WS77c1dbb1bd80d383527e1a6412a8a5d909a-8000.html#WSe11993ea1bd776e577ad4b2d12a42c5858a-7ffe"相对=nofollow>这是我发现这证实什么网络的其他部分一样。
This class is strangely undocumented. I have not tried this myself, but from searching online, this is what I found which corroborates with what the rest of the network does.
您需要做什么是泡沫事件到 TabbedViewNavigatorApplication
,并从那里更改的selectedIndex
属性为准选项卡,你需要改变。例如:
What you need to do is bubble an event to the TabbedViewNavigatorApplication
and from there change the selectedIndex
property to whichever tab you need to change to. For example:
<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>
您只需从你的孩子在调度冒泡事件。你可以创建事件,保存有关的选项卡切换到数据的自定义事件。
You just need to dispatch a bubbling event from within your children. You could event create a custom event that holds data about which tab to switch to.
这篇关于Flex的选项卡式ViewNavigators之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!