Home     |     Photoshop    |     Flash General    |     Flash Actionscript    |     Dreamweaver    |     Macromedia Fireworks


Cervo Technologies
The Right Source to Outsource

Macromedia Flash Actionscript

AS3 preloader works on Firefox but not IE7


Hi,
 I am new to Flash CS3 and Actionscript 3 so i'm not sure if this is an
elementary problem or not. I have some preloader code that works fineon all
browsers the first time it loads. Once loaded the page will no longer advance
past the first frame (where the preloader is located) on IE7. On firefox it
works great every time.

 Attached is the preloader code which is the Document class. I have it set to
export classes in frame 2 but it wasn't working when i had it in frame 1.
 Any help would be greately appreciated.
 Thanks,
 Dinko

 package {
        import flash.display.*;
        import flash.text.*;
        import flash.events.*;

        public class Preloader extends MovieClip {
                public static const ENTRY_FRAME:Number = 2;
                //public static const DOCUMENT_CLASS:String = 'Program';

                //private var progressBar:Sprite;
                private var txtLoaded:TextField;

                public function Preloader() {
                        super();
                        stop();
                        //progressBar = getChildByName("pBar") as Sprite;
                        txtLoaded   = getChildByName("txtPercentLoaded") as TextField;
                        //progressBar.scaleX = 0;
                        txtLoaded.text = "";

                        //what to do each time progress is made
                        loaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);

                        //what to do when this loader script is done
                        loaderInfo.addEventListener(Event.COMPLETE, completeHandler);
                }

                private function progressHandler(event:ProgressEvent):void {
                        var loaded:uint = event.bytesLoaded;
                        var total:uint = event.bytesTotal;
                        //progressBar.scaleX = loaded/total;
                        txtLoaded.text = String(Math.round(loaded/total*100)+"%");
                }

                private function completeHandler(event:Event):void {
                        play(); //play the movie when the loader is done
                        addEventListener(Event.ENTER_FRAME, enterFrameHandler);
                }

                private function enterFrameHandler(event:Event):void {
                        if (currentFrame >= Preloader.ENTRY_FRAME) {
                                removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
                                stop();
                                main();
                        }
                }

                private function main():void {

                }
        }
 }

I found something that worked. I hope this helps somebody. It works for me.

 1. I removed the "stop();" from frame 1.
 2. I changed the preloader code to read:

 package {
        import flash.display.*;
        import flash.text.*;
        import flash.events.*;

        public class Preloader extends MovieClip {
                public static const ENTRY_FRAME:Number = 2;

                //private var progressBar:Sprite;
                private var txtLoaded:TextField;

                public function Preloader() {
                        super();

                        //progressBar = getChildByName("pBar") as Sprite;
                        txtLoaded   = getChildByName("txtPercentLoaded") as TextField;

                        //progressBar.scaleX = 0;
                        txtLoaded.text = "";

                        loaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);

                        loaderInfo.addEventListener(Event.COMPLETE, completeHandler);
                }

                private function progressHandler(event:ProgressEvent):void {
                        var loaded:uint = event.bytesLoaded;
                        var total:uint = event.bytesTotal;

                        //progressBar.scaleX = loaded/total;
                        txtLoaded.text = String(Math.round(loaded/total*100)+"%");
                }

                private function completeHandler(event:Event):void {
                        play();
                        addEventListener(Event.ENTER_FRAME, enterFrameHandler);
                }

                private function enterFrameHandler(event:Event):void {
                        if (currentFrame >= Preloader.ENTRY_FRAME) {
                                removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
                                main();
                        }
                }

                private function main():void {

                }
        }
 }

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc