Flex页面的切换
目前学习到的方法主要有下面几种:1.navigateToURL 通过设定URL路径,进行页面切换<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx:Script>??? <![CDATA[??? ??? private function Link():void{??? ??? ??? var url:String="http://127.0.0.1:8080/Login/bin-debug/Login.html";//设置路径??? ??? ??? var request:URLRequest=new URLRequest(url);??? ??? ??? navigateToURL(request,"_top");//"_top"表示在当前页面显示,"_bank"在新页面显示??? ??? }??? ]]></mx:Script>??? <mx:Button x="94" y="80" label="LoginLink" click="Link()"/></mx:Application>2.利用ViewStack实现<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx:ViewStack id="VS" width="183" height="282" x="171" y="36">??? <mx:Canvas id="P">??? ??? <mx:Button label="Next" click="VS.selectedChild=N" x="43" y="89" width="75" height="39" fontSize="12"/>??? </mx:Canvas>??? <mx:Canvas id="N">??? ??? <mx:Button label="Pre" click="VS.selectedChild=P"? x="54.5" y="67" width="73" height="52" fontSize="12"/>??? </mx:Canvas></mx:ViewStack></mx:Application>3.State (登陆框的主要代码)<!--初始页面为login-->??? <mx:Panel x="228" y="35" width="250" height="275" layout="absolute" title="LOGIN FORM" fontSize="12" id="panel1">??? ??? <mx:Label x="10" y="10" text="User Id:" fontSize="10" id="label2"/>??? ??? <mx:TextInput x="10" y="27" id="usr_id"/>??? ??? <mx:Label x="10" y="70" text="Password:" fontSize="10" id="label1"/>??? ??? <mx:TextInput x="10" y="96" id="usr_pass" displayAsPassword="true"/>??? ??? <mx:Button x="10" y="147" label="Submit" click="login.send()" id="button1"/>??? ??? <mx:ControlBar height="36" y="207" id="controlbar1">??? ??? ??? <mx:LinkButton label="Register" click="currentState='Register'" id="linkbutton1"/>??? ??? </mx:ControlBar>??? </mx:Panel><!--设置页面register--><mx:states>??? <mx:State name="Register">??? ??? <mx:RemoveChild target="{label2}"/>??? ??? <mx:RemoveChild target="{usr_id}"/>??? ??? <mx:RemoveChild target="{label1}"/>??? ??? <mx:RemoveChild target="{usr_pass}"/>??? ??? <mx:RemoveChild target="{button1}"/>??? ??? <mx:SetProperty target="{panel1}" name="height" value="353"/>??? ??? <mx:AddChild relativeTo="{controlbar1}" position="before">??? ??? ??? <mx:Label x="10" y="10" text="Register ID:" fontSize="10"/>??? ??? </mx:AddChild>??? ??? <mx:AddChild relativeTo="{controlbar1}" position="before">??? ??? ??? <mx:TextInput x="10" y="36" id="rs_id"/>??? ??? </mx:AddChild>??? ??? <mx:AddChild relativeTo="{controlbar1}" position="before">??? ??? ??? <mx:Label x="10" y="68" text="Register Name:" fontSize="10"/>??? ??? </mx:AddChild>??? ??? <mx:AddChild relativeTo="{controlbar1}" position="before">??? ??? ??? <mx:TextInput x="10" y="94" id="rs_name"/>??? ??? </mx:AddChild>??? ??? <mx:AddChild relativeTo="{controlbar1}" position="before">??? ??? ??? <mx:Label x="10" y="126" text="Password:" fontSize="10"/>??? ??? </mx:AddChild>??? ??? <mx:AddChild relativeTo="{controlbar1}" position="before">??? ??? ??? <mx:TextInput x="10" y="152" id="rs_pass" displayAsPassword="true"/>??? ??? </mx:AddChild>??? ??? <mx:AddChild relativeTo="{controlbar1}" position="before">??? ??? ??? <mx:Label x="10" y="184" text="Repeat Password:" fontSize="10"/>??? ??? </mx:AddChild>??? ??? <mx:AddChild relativeTo="{controlbar1}" position="before">??? ??? ??? <mx:TextInput x="10" y="210" id="rs_password" displayAsPassword="true"/>??? ??? </mx:AddChild>??? ??? <mx:AddChild relativeTo="{controlbar1}" position="before">??? ??? ??? <mx:Button x="10" y="251" label="Register" click="register.send()"/>??? ??? </mx:AddChild>??? ??? <mx:SetProperty target="{linkbutton1}" name="label" value="Login"/>??? ??? <mx:SetEventHandler target="{linkbutton1}" name="click" handler="currentState=''"/>??? </mx:State></mx:states> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |