demo:https://github.com/victoryckl/flex-demos/tree/master/pagejump
?
http://www.voidcn.com/article/p-beodugpi-wg.html
一般有两种比较好的方式:"States" and "viewStack"
- <?xml?version="1.0"?encoding="utf-8"?>??
- <mx:Application?xmlns:mx="http://www.adobe.com/2006/mxml"?xmlns:view="view.*"???
- ????????creationComplete="initApp()"?horizontalAlign="center"?verticalAlign="middle">??
- ??????????????????
- ????????<mx:Style?source="style.css"?/>??
- ??????????
- ????????<mx:Script>??
- ????????????????<!--[CDATA[??
- ????????????????????????import?flash.events.Event??
- ????????????????????????import?mx.managers.CursorManager??
- ????????????????????????import?model.ModelLocator??
- ??????????????????????????
- ????????????????????????import?mx.controls.Alert??
- ????????????????????????private?var?instance:ModelLocator?=?ModelLocator.getInstance();??
- ????????????????????????internal?function?initApp():void{??
- ????????????????????????????????currentState="Login";??
- ??????????????????????????????????
- ????????????????????????????????instance.addEventListener(ModelLocator.LOGIN_OK,onLoginHandler)??
- ????????????????????????????????instance.addEventListener(ModelLocator.LOGIN_FAILED,onLoginFailHandler)??
- ????????????????????????}??
- ????????????????????????internal?function?onLoginHandler(evt:Event):void{??
- ????????????????????????????????currentState="Main";??
- ????????????????????????}??
- ????????????????????????internal?function?onLoginFailHandler(evt:Event):void{??
- ????????????????????????????????Alert.show("登陆失败,请重新输入!","密码错了!")??
- ????????????????]]-->??
- ????????</mx:Script>??
- ????????<mx:states>??????????
- ??????????????????
- ????????????????<mx:State?name="Login">??
- ????????????????????????<mx:AddChild?position="lastChild">??
- ????????????????????????????????<view:loginPanel?id="loginPanel"/>??
- ????????????????????????</mx:AddChild>??
- ????????????????</mx:State>??
- ??????????????????
- ????????????????<mx:State?name="Main">??
- ????????????????????????<mx:AddChild?position="lastChild">??
- ????????????????????????????????<view:main?id="mainApp"?/>??
- ????????????????????????</mx:AddChild>??
- ????????????????</mx:State>??????????????????
- ????????</mx:states>??
- ?????????<mx:transitions>??
- ????????<mx:Transition?fromState="*"?toState="*">??
- ????????????????<mx:Iris?xFrom="10"??targets="{[loginPanel,?mainApp]}"/>??
- ????????</mx:Transition>??
- ????????</mx:transitions>??
- ????????<mx:ApplicationControlBar?dock="true"?fillAlphas="[0.2,?0.7]"?>??
- ????????????????<mx:Label?text="名片管理"?/>??
- ????????????????<mx:Spacer?width="100%"?/>??
- ????????????????<mx:Label?id="txtWelcome"?visible="false"?/>??
- ????????</mx:ApplicationControlBar>??????????
- </mx:Application>