5 Replies Latest reply on Sep 19, 2009 1:08 PM by kglad

    Trace load progress then load new swf

    AESS1981 Level 1

      Hi, the following code traces the loading status of '1.swf', and once it has loaded, starts loading '2.swf':

       

      preload1.loadMovie("portfolio/100_design/1.swf");

      onEnterFrame = preLoadMeter;

      var tl:MovieClip = this;


      MovieClip.prototype.preLoadMeter = function() {

      var i, l, t;

      l = preload1.getBytesLoaded();

      t = preload1.getBytesTotal();

      if (t>0 && t == l) {

      delete tl.onEnterFrame;

      preload2.loadMovie("portfolio/100_design/2.swf");

      menu4.gotoAndPlay(1);

      } else {

      trace(l/t);

      }

      };

      I need this action to be repeated: ie. how do I trace the loading progress of "2.swf" (then trigger another action once fully loaded)?
      Should I make a new function or can something be bolted onto the existing code?
      Thanks

        • 1. Re: Trace load progress then load new swf
          kglad Adobe Community Professional & MVP

          you should start over.  your current code is problematic:

           

          var tl:MovieClip=this;

          var swfsToLoadA:Array=["portfolio/100_design/1.swf","portfolio/100_design/2.swf"];

          var loadTargetA:Array = [preload1,preload2];

           

          var index:Number=0;

          loadNextSWF(index);

           

          function loadNextSWF(){

          if(index<swfsToLoadA.length){

          loadTargetA[index].loadMovie(swfsToLoadA[index]);

          tl.onEnterFrame = preloadF;

          } else {

          delete tl.onEnterFrame;

          // do whatever.  preloading is complete

          }

          }

           

          function preloadF(){

          var bl:Number=loadTargetA[index].getBytesLoaded();

          var bt:Number=loadTargetA[index].getBytesTotal();

          if(bl>0&&bl>=bt){

          index++;

          loadNextSWF();

          }

          }

          • 2. Re: Trace load progress then load new swf
            AESS1981 Level 1

            Incredible! Works exactly as I had hoped.

             

            I am pushing my luck here, but once each image has loaded, is there a way that I can trigger a mc on the main stage?

             

            ie:

            once '2.swf' has loaded, tell mc "menu2"  to 'gotoAndPlay' (1)...

            once '3.swf' has loaded, tell mc "menu3"  to 'gotoAndPlay' (1)...

            once '4.swf' has loaded, tell mc "menu4"  to 'gotoAndPlay' (1)...

            Would arrays be used?

            Thanks again, your help is really appreciated.

            • 3. Re: Trace load progress then load new swf
              kglad Adobe Community Professional & MVP

              yes, you can use the following:  (and, if you can, mark this thread as answered)

               


               

              var tl:MovieClip=this;

              var swfsToLoadA:Array=["portfolio/100_design/1.swf","portfolio/100_design/2.swf"];

              var loadTargetA:Array = [preload1,preload2];

               

              var index:Number=0;

              loadNextSWF(index);

               

              function loadNextSWF(){

              if(index<swfsToLoadA.length){

              loadTargetA[index].loadMovie(swfsToLoadA[index]);

              tl.onEnterFrame = preloadF;

              } else {

              delete tl.onEnterFrame;

              // do whatever.  preloading is complete

              }

              }

               

              function preloadF(){

              var bl:Number=loadTargetA[index].getBytesLoaded();

              var bt:Number=loadTargetA[index].getBytesTotal();

              if(bl>0&&bl>=bt){

              tl["menu"+index].gotoAndPlay(1);

              index++;

              loadNextSWF();

              }

              }

              • 4. Re: Trace load progress then load new swf
                AESS1981 Level 1

                Perfect, that is a massive help!

                 

                Take care

                • 5. Re: Trace load progress then load new swf
                  kglad Adobe Community Professional & MVP

                  you're welcome.