10 Replies Latest reply: Jun 10, 2009 8:31 AM by kglad RSS

    Bizarre Problem

    Shane P Community Member

      Hello Everyone,

       

      I am having a rather strange problem with my Flash movie. I am not that experienced in Flash and was wondering if anyone here knew what the cause might be.

       

      I built a pretty simple Flash movie for a client and put a preloader on frame 1. The preloader works fine then the movie plays. What is happening is if you go to another page on the site and then go back to the home page all you see is the preloader bar fully loaded but the movie doesn't play. You have to refresh the page for the swf to play again.

       

      It is doing it to me in Firefox but not IE 8 and it is doing it in IE8 on my clients computer... I'm totally stumped, it's like a refresh issue or something. Any help would be greatly appreciated.

       

      Here is the code.

       

      stop();

      this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
      this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);

      function onProgress(e:ProgressEvent):void
      {
      var loaded:Number = e.target.bytesLoaded;
      var total:Number = e.target.bytesTotal;
      var pct:Number = loaded/total;
      loader_mc.scaleX = pct;
      loaded_txt.text="Loading..." + (Math.round(pct * 100)) + "%";
      }
      function onComplete(e:Event):void 
      {
      gotoAndPlay(2);
      }

       

       

      Anyone have ant idea why its doing this?

       

      Here is a screen cap of what is happening. After you go back to the homepage all you see is the rpeloader bar fully loaded without the load text.

      scrncap.jpg

        • 1. Re: Bizarre Problem
          kglad CommunityMVP

          no progress event is being triggered when you return.

           

          to remedy, either don't return to that frame or use a complete listener to trigger your advance to frame 2.

          • 2. Re: Bizarre Problem
            Shane P Community Member

            Thank you for the reply,

             

            How would I set it up so after the movie loads and a user goes off on another page and decides to come back to the home page it will automatically go to frame 2 and not frame 1 and go through the preloader code? I fairly new to actionscripting so I apologize if I am sounding like an idiot...lol

            • 3. Re: Bizarre Problem
              kglad CommunityMVP

              you already have an onComplete function.  just add:


               

              stop();

               

              var alreadyLoaded:Boolean;

              if(alreadyLoaded){

              onComplete(new Event("complete"));

              }

              this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
              this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);

              function onProgress(e:ProgressEvent):void
              {
              var loaded:Number = e.target.bytesLoaded;
              var total:Number = e.target.bytesTotal;
              var pct:Number = loaded/total;
              loader_mc.scaleX = pct;
              loaded_txt.text="Loading..." + (Math.round(pct * 100)) + "%";
              }


              function onComplete(e:Event):void 
              {

              alreadyLoaded=true;

              gotoAndPlay(2);
              }

               

               



              • 4. Re: Bizarre Problem
                Shane P Community Member

                Thank you for the reply, ill try this now.

                • 5. Re: Bizarre Problem
                  Shane P Community Member

                  It did not work, its still doing it in firefox......arghhhhh....heres the code in my fla

                   

                  stop();

                  var alreadyLoaded:Boolean;
                  if(alreadyLoaded){
                  onComplete(new Event("complete"));
                  }

                  this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
                  this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);

                  function onProgress(e:ProgressEvent):void
                  {
                  var loaded:Number = e.target.bytesLoaded;
                  var total:Number = e.target.bytesTotal;
                  var pct:Number = loaded/total;
                  loader_mc.scaleX = pct;
                  loaded_txt.text="Loading..." + (Math.round(pct * 100)) + "%";
                  }
                  function onComplete(e:Event):void 
                  {
                  alreadyLoaded=true;
                  gotoAndPlay(2);
                  }

                  • 6. Re: Bizarre Problem
                    kglad CommunityMVP

                    if your swf is not advancing to frame 2 then there's something else executing after that frame 1 code causing the problem.  if you see a momentary flash of your preloader and you want that removed, then use:

                     

                     

                    stop();

                    var alreadyLoaded:Boolean;
                    if(alreadyLoaded){
                    gotoAndPlay(2);
                    } else {

                    this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
                    this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);

                    }

                    function onProgress(e:ProgressEvent):void
                    {
                    var loaded:Number = e.target.bytesLoaded;
                    var total:Number = e.target.bytesTotal;
                    var pct:Number = loaded/total;
                    loader_mc.scaleX = pct;
                    loaded_txt.text="Loading..." + (Math.round(pct * 100)) + "%";
                    }
                    function onComplete(e:Event):void 
                    {

                    this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress);

                    this.loaderInfo.removeEventListener(Event.COMPLETE, onComplete);

                    removeChild(loader_mc);

                    removeChild(loaded_txt);

                    loader_mc=null;

                    loaded_txt=null;

                    alreadyLoaded=true;
                    gotoAndPlay(2);
                    }

                    • 7. Re: Bizarre Problem
                      Shane P Community Member

                      Thank you so much for your help but unfortunately that didnt work either. Here is the site if you would like to see for yourself. www.signheredocs.com

                      • 8. Re: Bizarre Problem
                        kglad CommunityMVP

                        i don't see a problem (except all those pages are slow to load).