as3.0中页面中嵌套加载页面



      今天想要实现页面中有个类似IFrame的层加载其他的flash。找到一个例子,可以通过,特地贴上来
ContractedBlock.gif ExpandedBlockStart.gif Code
default.mxml中
xml version="1.0" encoding="utf-8"?> 
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" 

creationComplete
="InitApp();"> 


<mx:Script> 
[CDATA[ 

var _Tab1: tab1 
= new tab1(); 

private function InitApp(): void 




private function OnBtn1Click(aEvent: MouseEvent): void 

                              
//创建类对象来加载. 
ml.url = ''
ml.addChild(_Tab1); 


private function OnBtn2Click(aEvent: MouseEvent): void 

if (ml.contains(_Tab1)) 

ml.removeChild(_Tab1); 

                                
//使用Module 
/*
  */ml.url = 'tab2.swf'


private function OnBtn3Click(aEvent: MouseEvent): void 

ml.url 
= 'tab2.swf'

]]
> 
mx:Script> 
<mx:Button x="21" y="28" label="Tab1" width="114" height="46" id="btn1" click="OnBtn1Click(event);"/> 
<mx:Button x="143" y="28" label="tab2" width="114" height="46" id="btn2" click="OnBtn2Click(event);"/> 
<mx:ModuleLoader x="0" y="91" width="100%" height="413" id="ml"> 
mx:ModuleLoader> 

mx:Application> 




 1 Module类型 类名tab1
 2
 3 xml version = " 1.0 "  encoding = " utf-8 " ?>  
 4 < mx:Module xmlns:mx = " http://www.adobe.com/2006/mxml "  width = " 624 "  height = " 484 "  backgroundColor = " #9DBEB4 " >  
 5 < mx:Label x = " 222 "  y = " 204 "  text = " I'm tab1 "  width = " 180 "  height = " 76 "  fontSize = " 30 " />  
 6 mx:Module >  
 7
 8
 9
10

1 tab2中
2
3
4 xml version = " 1.0 "  encoding = " utf-8 " ?>  
5 < mx:Module xmlns:mx = " http://www.adobe.com/2006/mxml "  layout = " absolute "  width = " 602 "  height = " 452 "  backgroundColor = " #734646 " >  
6 < mx:Label x = " 222 "  y = " 204 "  text = " I'm tab2 "  width = " 180 "  height = " 76 "  fontSize = " 30 " />  
7 mx:Module >  

转载于:https://www.cnblogs.com/aaa1028/archive/2009/10/14/1583293.html

你可能感兴趣的:(as3.0中页面中嵌套加载页面)