在 Flex 选项卡式 ViewNavigators 之间切换 [英] Switch between Flex Tabbed ViewNavigators

查看:18
本文介绍了在 Flex 选项卡式 ViewNavigators 之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个带有三个选项卡(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).

我知道在视图之间切换使用 pushViewpopView,但我正在使用 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>

感谢您的帮助!

推荐答案

这个类奇怪地没有记录.我自己没有尝试过,但是从网上搜索,

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆