Any idea why there are no errors but my preloader does not show up 
on the stage? I have commented out the call to remove it and 
addChild the main website for testing purposes ...

package {

        // Flash Classes
        import flash.display.*;
        import flash.events.*;
        import flash.net.*;     

        [SWF(backgroundColor="#58585A", width="1000", height="600", 
frameRate="30", quality="HIGH")]

        public class preloader extends Sprite {
                private var _loader:Loader;
                private var _preloader:Sprite;
                private var _request:URLRequest;
                private var _main:* = null;
                
                // Preload External SWF with a Preloader Bar
                public function preloader() {
                        _preloader = new Sprite();
                        _preloader.graphics.beginFill(0xFFFF00, 1);
                        _preloader.graphics.drawRect(0, 0, 400, 1);
                        _preloader.graphics.endFill();
                        _preloader.x = (stage.stageWidth - _preloader.width) / 
2;
                        _preloader.y = (stage.stageHeight - _preloader.height) 
/ 2;
                        _preloader.scaleX = 0;
                        _loader = new Loader();
                        _request = new URLRequest("main.swf");
                        addChild(_preloader);
                        
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, 
ioError);
                        
_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, 
loadProgress);
                        
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, 
loadComplete);
                        try {
                                _loader.load(_request);
                        } catch (error:SecurityError) {
                                trace(error);
                        }
                }
                
                // Display Load Progress
                private function loadProgress(event:ProgressEvent):void {
                        var percentLoaded:Number = 
event.bytesLoaded/event.bytesTotal;
                        _preloader.scaleX = percentLoaded;
                }

                // Loading is Complete
                private function loadComplete(event:Event = null):void {
                        _main = _loader.content;
                        initMain();
                }
                
                // Main Post-Load Function
                private function initMain():void {
                        //removeChild(_preloader);
                        //addChild(_main);
                }
                
                private function ioError(event:IOErrorEvent):void {
                        trace(event);
                }
        }
}

--
Click for free info on getting an MBA, $200K/ year potential.
 
http://tagline.hushmail.com/fc/PnY6qxsZwUO5pG5CVtxb0vjaqHc2pQZU8KxeuZzCNRjEbyMa6YniX/

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to