在 Flex 选项卡式 ViewNavigator 之间切换

发布于 2024-11-09 23:33:14 字数 947 浏览 4 评论 0原文

我正在开发一个带有三个选项卡(ViewNavigator 元素)的 Flex TabbedViewNavigatorApplication。我想根据用户操作(通过 ActionScript 代码)从一个 ViewNavigator 切换到另一个 ViewNavigator。

我知道在视图之间切换使用 pushViewpopView,但我正在使用 ViewNavigators,并且我的搜索没有发现任何有用的信息。

当事件发生时,我尝试从 Tab2 切换到 Tab1。在本例中,Tab2 包含一个列表,当用户进行选择时,我想跳回 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>

感谢您的帮助!

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).

I know that switching between Views uses pushView and popView, but I'm working with ViewNavigators, and my searching revealed nothing useful.

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦过后 2024-11-16 23:33:14

我使用以下 ActionScript 行根据用户操作从一个 ViewNavigator 切换到另一个:

TabbedViewNavigator(navigator.parentNavigator).selectedIndex = 1;

它的工作方式就像一个魅力,并且看起来比冒泡事件更简单。

I use the following line of ActionScript to switch from one ViewNavigator to another based on a user action:

TabbedViewNavigator(navigator.parentNavigator).selectedIndex = 1;

It worked like a charm and seems simpler than bubbling events.

鲸落 2024-11-16 23:33:14

奇怪的是,这个类没有记录。我自己没有尝试过,但是通过在线搜索, 这是我发现的,它证实了网络其他部分的做法。

您需要做的是将事件冒泡到 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>

您只需要从您的孩子内部调度一个冒泡事件。您可以创建一个自定义事件来保存有关要切换到哪个选项卡的数据。

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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文