flex mobile TabbedViewNavigatorApplication back button

故事扮演 提交于 2019-12-12 03:16:36

问题


Why TabbedViewNavigatorApplication don’t have popView() (as in ViewNavigatorApplication I can use popView to go previous view)?

How can I do that in TabbedViewNavigatorApplication?

    <fx:Script>
    <![CDATA[      
      protected function BackBtn(event:MouseEvent):void{
        navigator.popView(); //error
      }
    ]]>
  </fx:Script>

<s:ViewNavigator label="Page1" width="100%" height="100%" firstView="views.DurationView" >
    <s:titleContent>
      <s:Button label="Back" click="BackBtn(event)"/>
    </s:titleContent>
  </s:ViewNavigator>
<s:ViewNavigator label="Page2" width="100%" height="100%" firstView="views.FrequencyView"/>
</s:TabbedViewNavigatorApplication>

thanks.


回答1:


<?xml version="1.0" encoding="utf-8"?>
<s:TabbedViewNavigatorApplication creationComplete="tabbedviewnavigatorapplication1_creationCompleteHandler(event)"
                                  xmlns:fx="http://ns.adobe.com/mxml/2009"
                                  xmlns:s="library://ns.adobe.com/flex/spark">
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;

            import spark.events.IndexChangeEvent;

            private var tabHistory : Array;
            private var isLoadingFromHistory : Boolean;

            protected function BackBtn(event : MouseEvent) : void
            {
                isLoadingFromHistory = true;
                if (tabHistory.length == 0)
                {
                    trace("You can't go back any further");
                    tabHistory.push(0);
                }
                tabbedNavigator.selectedIndex = tabHistory.pop();
            }

            protected function tabbedviewnavigatorapplication1_creationCompleteHandler(event : FlexEvent) : void
            {
                tabHistory = [];
                tabbedNavigator.addEventListener(IndexChangeEvent.CHANGE, tabsChangedHandler);
            }

            private function tabsChangedHandler(event : IndexChangeEvent) : void
            {
                if (isLoadingFromHistory)
                {
                    isLoadingFromHistory = false;
                    return;
                }
                tabHistory.push(event.oldIndex);
                trace(tabHistory);
            }
        ]]>
    </fx:Script>

    <s:ViewNavigator firstView="views.WhosAtTheDoorHomeView"
                     height="100%"
                     label="Page1"
                     width="100%">
        <s:titleContent>
            <s:Button click="BackBtn(event)"
                      label="Back"/>
        </s:titleContent>
    </s:ViewNavigator>
    <s:ViewNavigator firstView="views.WhosAtTheDoorHomeViewCopy"
                     height="100%"
                     label="Page2"
                     width="100%">
        <s:titleContent>
            <s:Button click="BackBtn(event)"
                      label="Back"/>
        </s:titleContent>
    </s:ViewNavigator>
</s:TabbedViewNavigatorApplication>


来源:https://stackoverflow.com/questions/9219760/flex-mobile-tabbedviewnavigatorapplication-back-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!