I would like to load external child swf into the parent swf (under same directory). I did try, the child loaded but the class in it didn't work.
1) How can i load the class of child swf?
2) How can i unload the class of child swf?(becoz there could be many ext. swf with different class)
thx
main.fla
game1.flaCode:function startLoad(){ var mLoader:Loader = new Loader(); var mRequest:URLRequest = new URLRequest("game1.swf"); var mLoaderContext:LoaderContext = new LoaderContext(false,ApplicationDomain.currentDomain); mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler); mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler); mLoader.load(mRequest, mLoaderContext); } function onCompleteHandler(loadEvent:Event){ var keyManager:Class = ApplicationDomain.currentDomain.getDefinition("net.keithhair.KeyManager") as Class; addChild(loadEvent.currentTarget.content); }
Result:Code:Code: import net.keithhair.KeyManager; keyManager=new KeyManager(stage); keyManager.addKey(["a"], doSomething); function doSomething():void { //do something }
Code:Code: TypeError: Error #1009: Cannot access a property or method of a null object reference.at net.keithhair::KeyManager/removeListeners() at net.keithhair::KeyManager/addListeners() at net.keithhair::KeyManager() at game1_fla::MainTimeline/frame1()




Reply With Quote
