[COLOR=#000000][FONT=Arial]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.[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]1) How can i load the class of child swf?[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]2) How can i unload the class of child swf?(becoz there could be many ext. swf with different class)[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]thx
[/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]main.fla[/FONT][/COLOR]
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);
}
[COLOR=#000000][FONT=Arial]game1.fla[/FONT][/COLOR]
import net.keithhair.KeyManager;
keyManager=new KeyManager(stage);
keyManager.addKey(["a"], doSomething);
function doSomething():void {
//do something
}
Result:
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()