3

我正在尝试使用登录视图(无标签)构建应用程序,在用户提交“登录”后,它将切换到另一个主视图(带有标签)。这可能吗?

目前我选择了应用程序模板下的“选项卡式应用程序”。
为了使标签栏隐藏,我尝试了:

protected function view1_activateHandler(event:Event):void
        {
            // TODO Auto-generated method stub
            this.tabBarVisible = false;
        }

..但是在运行应用程序时隐藏有一个向下滑动的动画(意味着它不会立即隐藏)
另外,如果切换到主视图,登录选项卡(属于 LoginView)按钮将在我没有的选项卡栏上想。

还有其他方法吗?我对 Flash Builder/Flex 4.5 还很陌生。帮助

我需要 10 个声望点才能发布图片 =.= 抱歉,我想发布屏幕截图以便更好地理解。还有 4 点要走):

4

1 回答 1

5

您应该将视图元素中的 tabBarVisible 属性设置为 false,然后在登录后更改它,如下所示:

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    tabBarVisible="false"
    title="My View" />

当您想要显示视图时,只需通过将 this.tabBarVisible 设置为 true 来让您的函数显示栏。

public function loginHandler():void {
    // Do login activities
    this.tabBarVisible = true;
}

这是我在评论中提到的...

主要.mxml:

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:components="components.*"
          creationComplete="creationCompleteHandler(event)">
<fx:Script>
    <![CDATA[
        import mx.events.FlexEvent;

        private static var app:Main;

        public static function login():void {
            app.loginComponent.visible = false;
            app.navigator.visible = true;
        }

        protected function creationCompleteHandler(event:FlexEvent):void {
            app = this;
        }

    ]]>
</fx:Script>

<components:LoginComponent id="loginComponent" left="0" right="0" top="0" bottom="0" />


<s:TabbedViewNavigator id="navigator" left="0" right="0" top="0" bottom="0" visible="false">
    <s:ViewNavigator id="testView1" width="100%" height="100%" label="Test 1" firstView="views.TestView1" />
    <s:ViewNavigator id="testView2" width="100%" height="100%" label="Test 2" firstView="views.TestView2" />
</s:TabbedViewNavigator>

我在这里所做的是创建一个默认应用程序,其中包含一个简单的登录组件,如下所示......

登录组件.mxml:

<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script>
    <![CDATA[
        protected function login(event:MouseEvent=null):void {
            Main.login();
        }
    ]]>
</fx:Script>

<s:VGroup left="0" right="0" top="0" bottom="0" horizontalAlign="center" horizontalCenter="0"
          verticalAlign="middle" verticalCenter="0">
    <s:HGroup left="0" right="0" height="75" horizontalAlign="left" verticalAlign="middle">
        <s:Label text="User Name"/>
        <s:Spacer width="10" height="10"/>
        <s:TextInput id="usernameInput" width="200"/>
    </s:HGroup>
    <s:HGroup left="0" right="0" height="75" verticalAlign="middle">
        <s:Label text="Password"/>
        <s:Spacer width="18" height="10"/>
        <s:TextInput id="passwordInput" width="200" displayAsPassword="true" enter="login()"/>
    </s:HGroup>
    <s:HGroup left="0" right="0" height="75" verticalAlign="middle" horizontalAlign="center" gap="20">
        <s:Button label="Login" click="login(event)" id="btnLogin"/>        
    </s:HGroup>
</s:VGroup>

这使我可以拥有一个我刚刚在组件中创建并作为启动屏幕嵌入到主应用程序中的登录屏幕,并且可以随意显示/隐藏 TabbedViewNavigator。我还没有尝试使用从一个应用程序启动到下一个应用程序来查看状态是如何维护的(即,如果您想要持久登录,您可能可以在创建完成处理程序中进行一些验证,但这取决于您观点)。

于 2011-08-23T15:12:57.653 回答