Preloader Problem with AS3 Document classes

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 );

function onCompleteHandler(loadEvent:Event) {
function onProgressHandler(mProgress:ProgressEvent) {
var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
lbar.scaleX = percent;

function loadComplete( e : Event ):void {

this.addChild( this.appLoader );


Try the INIT event, instead of complete, as this lets the loaded swf’s AS initialise.

Thanks Dail. And interesting idea but it still returns Error 1009. Do I need to change the code more to make this work?