Preloading SWF tied to document class... confused

I have a file called “externalpreloader.swf”. On the first frame I have code to load “main.swf”…

main.swf has a few clips on stage, but all other clips & images are pulled in from the library at runtime. main.swf is tied to a document class called “mainflow.as”. Then of course there are other classes associated with mainflow.as, etc.

So that should seem pretty straightforward. The result is also pretty straightforward; when the preloader finishes, I get only what’s already added to stage… not any of the library items.

But I’m very confused as to how I can preload the entire swf, library files & all…

What’s the right method? The code is below:


var loader:Loader;

loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, contentComplete);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, contentProgress);
loader.load(new URLRequest("main.swf"));
        
function contentComplete(e:Event):void {
    // add loader
    addChild(loader);
}
        
function contentProgress(e:Event):void {
    var total:Number = e.target.bytesTotal;
    var loaded:Number = e.target.bytesLoaded;
    mcPercent.text = Math.floor((loaded / total) * 100).toString() + "%";
    mcBar.scaleX = loaded / total;
    trace(mcBar.scaleX);
            
    // hide loader visuals
    if (mcBar.scaleX == 1) {
    mcBar.visible = false;
    mcPercent.visible = false;
    }
}

Appreciate any help on this? For convenience, here it is in a class:


package {
    import flash.display.MovieClip;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.ProgressEvent;
    import flash.net.URLRequest;
    import flash.display.Loader;
    import flash.text.TextField;
    
    public class Preloader extends Sprite {
        private var loader:Loader;
        
        public function Preloader(_file:String) {        
            // load swf
            var file:String = _file;
            loader = new Loader();
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, contentComplete);
            loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, contentProgress);
            loader.load(new URLRequest(file));
        }
        
        private function contentComplete(e:Event):void {
            // add loader
            addChild(loader);
        }
        
        private function contentProgress(e:Event):void {
            var total:Number = e.target.bytesTotal;
            var loaded:Number = e.target.bytesLoaded;
            root["mcPercent"].text = Math.floor((loaded / total) * 100).toString() + "%";
            root["mcBar"].scaleX = loaded / total;
            
            // hide loader visuals
            if (root["mcBar"].scaleX == 1) {
                root["mcBar"].visible = false;
                root["mcPercent"].visible = false;
            }
        }
        
    }
}