首先, ViewStack是一个导航容器。默认情况下,这个导航容器是看不见的。ViewStack里面可以堆叠一组子容器,但是每次只能显示一个子容器。举例说明:
现在有一个登录页面,当登录成功后,页面跳转到操作页面。
先定义ViewStack,代码如下
<mx:Script>
<![CDATA[
private function init():void{
var loginPage:UserLogin=new UserLogin();
loginPage.name="loginPage";
mainContainer.addChild(loginPage);
}
]]>
</mx:Script>
<mx:ViewStack width="100%" height="100%" id="mainContainer"/>
在页面初始化的时候,把登陆页面加载到ViewStack容器里面。
登录页面代码如下
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%"
horizontalAlign="center" verticalAlign="middle">
<mx:Script>
<![CDATA[
[Embed(source='assets/style/images/login_back.png')]
[Bindable]private var bdImg:Class;
]]>
</mx:Script>
<mx:HBox width="60%" height="60%" backgroundImage="{bdImg}" verticalAlign="middle" >
<mx:HBox width="300"/>
<mx:VBox width="60%" verticalGap="10">
<mx:HBox width="100%">
<mx:Label text="用户名"/>
<mx:TextInput width="200"/>
</mx:HBox>
<mx:HBox width="100%">
<mx:Label text="密 码"/>
<mx:TextInput width="200"/>
</mx:HBox>
<mx:HBox width="100%">
</mx:HBox>
</mx:VBox>
</mx:HBox>
</mx:VBox>