---
title: "MXML里跳页面"
author: "zwh910621"
date: "2009-11-27T22:11:27Z"
tags: []
categories: ["Web前端"]
slug: "mxml"
draft: false
lastmod: "2010-03-03T15:06:27Z"
id: 531528
url: "https://javaheart88.iteye.com/blog/531528"
---

```
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">	
	<mx:Script>
		<![CDATA[
			function skip_html_localhost(){
				//var url:String="/test/index.html";//跳HTML
				var url:String="viewStack.html";//跳MXML
，swf文件（这里是编译后的HTML）				var request:URLRequest=new URLRequest(url);
				navigateToURL(request);
			}
		]]>
	</mx:Script>

	<mx:Panel x="233" y="247" title="跳转页面（本地）">
		<mx:Button label="skip" click="skip_html_localhost();"/>
	</mx:Panel>
</mx:Application>
```

 MXML里跳页面

```
private function login():void{navigateToURL(newURLRequest("/test/flex/Login.html"),"_self");
} 
```

 上面跳转URL指向的必须是 MXML Application

如果是Module还可以用viewStack来实现

```
<mx:ViewStack id="views" creationPolicy="all" width="100%" height="80%">
	<mx:ViewStack id="theNULL">
		
	</mx:ViewStack>
	<animal:Animal id="animalView" showEffect="WipeDown" hideEffect="WipeUp" width="100%" height="100%"/>
	<artefact:Artefact id="artefactView" showEffect="WipeDown" hideEffect="WipeUp"/>
	<house:House id="houseView" showEffect="WipeDown" hideEffect="WipeUp"/>
	<insect:Insect id="insectView" showEffect="WipeDown" hideEffect="WipeUp"/>
	<mountain:Mountain id="mountainView" showEffect="WipeDown" hideEffect="WipeUp"/>
	<tree:Tree id="treeView" showEffect="WipeDown" hideEffect="WipeUp"/>
	
	<animal:AnimalType id="animalTypeView" showEffect="WipeDown" hideEffect="WipeUp"/>
	<artefact:ArtefactType id="artefactTypeView" showEffect="WipeDown" hideEffect="WipeUp"/>
</mx:ViewStack>


private function changeView():void{
	views.selectedChild=animalView;				
}
```