View Code
 1 package
 2 {
 3     import flash.display.Loader;
 4     import flash.display.Sprite;
 5     import flash.events.Event;
 6     import flash.net.URLRequest;
 7     import flash.system.ApplicationDomain;
 8     import flash.system.LoaderContext;
 9     import flash.system.SecurityDomain;
10     import flash.utils.getDefinitionByName;
11     
12     public class Test extends Sprite
13     {
14         public function Test()
15         {
16             var url:URLRequest=new URLRequest("asset/securityTest.swf");
17             var loadercontext:LoaderContext=new LoaderContext();
18             loadercontext.applicationDomain= ApplicationDomain.currentDomain;
19             
20             var loader:Loader=new Loader();
21             loader.load(url,loadercontext);
22             this.addChild(loader);
23 //            var loader:Loader=new Loader();
24 //            loader.load(url);
25             loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onload);
26             
27         }
28         private function onload(e:Event):void
29         {
30 //            var myclass:Class=getDefinitionByName("securityTest") as Class;
31 //            trace(typeof(myclass));
32 //            var myc:Object=new myclass();
33 //            trace(myc["out"]);
34             e.target.content.out();
35             
36         }
37     }
38 }

[as3.0]调用加载的SWF文件的函数

 
 在使用as3.0中,想要一个SWF文件(假设为1.swf)加载另一个SWF文件(假设为2.swf),并且1.swf调用2.swf文件里的方法,方法如下:
1.swf:
[as3.0]调用加载的SWF文件的函数var url:String = "2.swf";
[as3.0]调用加载的SWF文件的函数
var req:URLRequest = new URLRequest(url);
[as3.0]调用加载的SWF文件的函数
var myLoader:Loader = new Loader();
[as3.0]调用加载的SWF文件的函数myLoader.load(req);
[as3.0]调用加载的SWF文件的函数myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
[as3.0]调用加载的SWF文件的函数
2.swf:
}

相关文章: