Flex 页面跳转的几种方法总结
相信好多人在做Flex的页面跳转时都遇到过问题,现打Flex实现页面跳转的实现方法总结一下
1、ViewStack,TabNavigator之类的组件
把页面做成Component然后用ViewStack包含进来,实现页面之间的切换,而HTML并没有刷新,ViewStack只是实现了flash里面的页面切换。
view plaincopy to clipboardprint?
1. <mx:ViewStack id="storeViews" width="100%" height="550" creationPolicy="all">
2. <shouye id="page1" label="page1" showEffect="WipeDown" hideEffect="WipeUp" />
3. <leixing id="page2" label="page2" showEffect="WipeDown" hideEffect="WipeUp" />
4. <make id="page3" label="page3" showEffect="WipeDown" hideEffect="WipeUp" />
5. </mx:ViewStack>
6. <!-- 然后再用别的组件切换这些页,比如用 Button -->
7. <mx:Button click="storeViews.selectedChild=page1;" />
<mx:ViewStack id="storeViews" width="100%" height="550" creationPolicy="all"> <shouye id="page1" label="page1" showEffect="WipeDown" hideEffect="WipeUp" /> <leixing id="page2" label="page2" showEffect="WipeDown" hideEffect="WipeUp" /> <make id="page3" label="page3" showEffect="WipeDown" hideEffect="WipeUp" /> </mx:ViewStack> <!-- 然后再用别的组件切换这些页,比如用 Button --> <mx:Button click="storeViews.selectedChild=page1;" />
2、flash.net.navigateToURL直接页面重定向
navigateToURL (request:URLRequest, window:String = null):void
在包含 Flash Player 容器的应用程序(通常是一个浏览器)中,打开或替换一个窗口。
如
view plaincopy to clipboardprint?
1. var
2. request:URLRequest = new URLRequest("163.com");
3. navigateToURL(request,"_blank");
var request:URLRequest = new URLRequest("163.com"); navigateToURL(request,"_blank");
3、flash.external.ExternalInterface调用外部 API
call (functionName:String, ... arguments):*
[] 调用由 Flash Player 容器公开的函数,不传递参数或传递多个参数。
view plaincopy to clipboardprint?
1. ExternalInterface.call("
2. function(){
3. window.location.href='http://163.com';
4. }");
ExternalInterface.call(" function(){ window.location.href='http://163.com'; }");
4、弹出页面类mx.managers.PopUpManager之类
用PopUpManager的createPopUp方法新建一个组新然后Pop出来
PopUpManager.centerPopUp(PopUpManager.createPopUp(this, Comp, true));
5、mx.modules.loadModule方法加载子模块
view plaincopy to clipboardprint?
1. public function jumpTo(toUrl:String):void
2. {
3. m1.url=toUrl;
4. m1.loadModule();
5. }
6. //其它地方法调用
7. this.parentApplication.jumpTo(url);
public function jumpTo(toUrl:String):void { m1.url=toUrl; m1.loadModule(); } //其它地方法调用 this.parentApplication.jumpTo(url);
就写这些了,你们谁要是有别的方法请也告诉我,大家分享