5 Replies Latest reply: Jun 30, 2013 6:47 PM by kglad RSS

    Preloader works differently in IE vs others

    jurneys Community Member

      Hi all,

       

      I made preloader code by myself, put into my hp's Main.swf.

       

      It works perfectly in IE, shows the background image then shows progress, counter is smoothly rise up and when reach to 100%, goes to main contents.

       

      But in Chrome and Firefox, shows background image, but counter does not appear until the contents are fully loaded, and then suddenly go up to 100%, then goes to main contents.

       

      This is my url,

      http://bootlegbaby.web.fc2.com/

       

      And this is the code I made for preloader

       

      ------------------------------------------------------------------------------------------ ---------

       

      stage.showDefaultContextMenu = false;

      Security.allowDomain("*");

      stage.scaleMode = StageScaleMode.NO_SCALE;

      stage.align = StageAlign.TOP_LEFT;

      var rx = Capabilities.screenResolutionX;

      var ry = Capabilities.screenResolutionY;

       

      //----------------------- Preloader Setup ------------------------------

       

       

      PreloaderHolder_mc.x = stage.stageWidth/2;

      PreloaderHolder_mc.y = stage.stageHeight/2 - 50;

      PreloaderBG_mc.width = stage.stageWidth;

      PreloaderBG_mc.height = stage.stageHeight;

       

       

      stage.addEventListener(Event.RESIZE,PLresizeHandler);

       

       

      function PLresizeHandler(event:Event):void {

                PreloaderHolder_mc.x = stage.stageWidth/2;

                PreloaderHolder_mc.y = stage.stageHeight/2 - 50;

                PreloaderBG_mc.width = stage.stageWidth;

                PreloaderBG_mc.height = stage.stageHeight;

                }

       

       

      var loader = new Loader();

      loader.load(new URLRequest("Main.swf"));

      loader.visible = false;

      addChild(loader);

      import flash.utils.Timer;

       

       

      loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);

      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

       

       

      function onProgress(e:ProgressEvent):void {

                var loadedBytes:int = Math.round(e.target.bytesLoaded / 1024); 

          var totalBytes:int = Math.round(e.target.bytesTotal / 1024); 

          var percent:int = (e.target.bytesLoaded / e.target.bytesTotal) * 100; 

                PreloaderHolder_mc.status_txt.text = String(loadedBytes + " of " + totalBytes + "KB Loaded\n" + percent + "% Complete");

      }

       

       

      function onComplete(e:Event):void {

                stop();

                var waitTime:Timer = new Timer(1000, 1);

                waitTime.start();

                waitTime.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);

       

                function onTimerComplete(event:TimerEvent):void{

                          removeChild(loader);

                          stage.removeEventListener(Event.RESIZE,PLresizeHandler);

                          loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress);

                          loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onComplete);

                          waitTime.removeEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);

                          removeChild(PreloaderBG_mc);

                          removeChild(PreloaderHolder_mc);

                          gotoAndPlay("Home");

                          }

      }

       

       

      stop();

       

      ------------------------------------------------------------------------------------------ ---------

       

      I am putting this code at 1st frame of Main.swf, then put contents after 2nd frame.

       

      Those movie clips called in this code are directly put into the scene at 1st frame.

       

      PreloaderHolder_mc

      PreloaderBG_mc

       

      Anyone have any idea to solve this issue?

       

      Message was edited by: jurneys

        • 1. Re: Preloader works differently in IE vs others
          kglad CommunityMVP

          here are some of the errors on your site:

           

          PreloadSwf  paths did not exist: /Users/kglad99/Library/Application  Support/Firefox/Profiles/htap5ygs.default/extensions/flashbug@coursevector.com/chrome/content/flashbug/profiler.swfPreloadSwf  paths did not exist: /Users/kglad99/Library/Application  Support/Firefox/Profiles/htap5ygs.default/extensions/flashbug@coursevector.com/chrome/content/flashbug/profiler.swf
          at MethodInfo-4394()
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at flash.utils::Timer/tick()
          TypeError: Error #1009: Cannot access a property or method of a null object reference.
          at MethodInfo-4394()
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at flash.utils::Timer/tick()
          TypeError: Error #1009: Cannot access a property or method of a null object reference.
          at MethodInfo-4394()
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at flash.utils::Timer/tick()
          TypeError: Error #1009: Cannot access a property or method of a null object reference.
          at MethodInfo-4394()
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at flash.utils::Timer/tick()
          TypeError: Error #1009: Cannot access a property or method of a null object reference.
          at MethodInfo-4394()
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at flash.utils::Timer/tick()
          TypeError: Error #1009: Cannot access a property or method of a null object reference.
          at MethodInfo-4394()
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at flash.utils::Timer/tick()
          TypeError: Error #1009: Cannot access a property or method of a null object reference.
          at MethodInfo-4394()
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at flash.utils::Timer/tick()
          TypeError: Error #1009: Cannot access a property or method of a null object reference.
          at AS3glow_mc/frame1()
          TypeError: Error #1009: Cannot access a property or method of a null object reference.
          at MethodInfo-4394()
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at flash.utils::Timer/tick()
          Log cleared
          • 2. Re: Preloader works differently in IE vs others
            jurneys Community Member

            I have separated preloader and main, now preloader's counter runs up smoothly in Chrome and Firefox too.

             

            But another problem happens, it doesn't shows opening animation that I set into the timeline of main, maybe because it is already played while preloader is loading main.

             

            Any way to suspend loader content's animation until loading complete?

            • 3. Re: Preloader works differently in IE vs others
              kglad CommunityMVP

              add a stop to your timeline in main and add a play to your loader's content cast as a movieclip after loading is complete.

              • 4. Re: Preloader works differently in IE vs others
                jurneys Community Member

                Works perfectly in all browsers now. Thanks for help!

                • 5. Re: Preloader works differently in IE vs others
                  kglad CommunityMVP

                  you're welcome.