I am building a FLA file that has a document class "Main" and in its constructor i have told it to trace(stage). I added an external preloader to load this SWF but what do you know, the trace statement is showing NULL.
Here is the preloader that is currently working.
import flash.display.Loader;
import flash.events.ProgressEvent;
import flash.events.Event;
import flash.net.URLRequest;
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
l.load(new URLRequest("Main.swf"));
function onProgress(e:ProgressEvent):void {
preloader.mask.height = (e.bytesLoaded / e.bytesTotal) * preloader.lemon.height;
}
function onComplete(e:Event):void {
removeChildAt(0);
}
For the Main.swf itself here is the document class:
package {
import Position;
import flash.display.*;
import flash.events.Event;
public class Main extends MovieClip {
public function Main():void {
trace(stage);
}
}
}
////SOLVED/// I forgot to add the item to the stage but luckily in phillip's code i saw this. So just remember once the Event.COMPLETE fires, add the contents of the loader to the stage else the document class for the swf will show null.