Hi, a friend and I have been working for months on a Flash/AS3 video game, and we’re stumped on one issue, the preloader. We need to either preload the game, which uses all document class as files, either within the timeline of the main swf, or into another swf. We’ve tried both options and we always get a 1009 Error, accessing a null class.
I thought this post would fix the problem:
But I can’t get it to work. I can’t figure out how to add the main class to the display list, and have everything reference the stage.
Has anyone run into this problem?
Any suggestions?
The preloader we want is quite simple:
package code {
public class Preloader extends MovieClip {
var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest(“xxx.swf”);
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
mLoader.contentLoaderInfo.addEventListener( Event.ADDED_TO_STAGE, this.loadComplete );
mLoader.load(mRequest);
function onCompleteHandler(loadEvent:Event) {
addChild(loadEvent.currentTarget.content);
}
function onProgressHandler(mProgress:ProgressEvent) {
var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
trace(percent);
lbar.scaleX = percent;
}
function loadComplete( e : Event ):void {
this.addChild( this.appLoader );
}
}
}