用反射在运行时拿到加载进来的swf的Class
package { import flash.display.MovieClip; import flash.display.Loader; import flash.net.URLRequest; import flash.events.Event; import flash.display.DisplayObject; import flash.system.ApplicationDomain; import flash.utils.getDefinitionByName; /* * * 用反射在运行时拿到加载进来的swf的Class */ public class Main extends MovieClip { private var loader : Loader = new Loader(); private var path : URLRequest = new URLRequest("Test.swf"); //要加载的swf public function Main() { loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded); loader.load(path); } private function loaded(evt : Event) : void{ trace(evt.target); var swf : DisplayObject = evt.target.content as DisplayObject; addChild(swf); var classRef : Object = swf.loaderInfo.applicationDomain.getDefinition("Test"); //获取加载进来的swf的Class引用 var ff : DisplayObject = new classRef()as DisplayObject; //创建一个新的Test类的实例 addChild(ff); ff.x = 100; } } }