I have something planned for The Games Collective
bricolage pageant, but I've ran into a problem. Is there a way to load a Flash game in SWF form into Flash without there being issues? I believe that these are related to the preloader in the loaded game, since it means that it starts running before it is fully loaded and put on the stage.
My code:
public class Main extends Sprite {
public function Main():void {
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
var loader:Loader = new Loader;
var request:URLRequest = new URLRequest("viewpoints.swf");
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
loader.load(request);
}
private function onLoaded(e:Event):void {
addChild(e.currentTarget.content);
}
}
And the error thrown is:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at perspective3_fla::MainTimeline().perspective3_fla is the loaded game, not this one. It errors before the 'complete' event is triggered, too.
Is there a way around this?