1 Reply Latest reply on Apr 15, 2009 4:49 AM by RossRitchey

    Can I have multiple individual/independent  Flash movies load in sequence?

      Hello. I have published to html 4 different and individual Flash movies which are on the same html web page. Is it possible for them to load in sequence to break up the total load time of all four movies?

       

      For example: Movie one which has a pre-loader starts loading, and when finished, it is playable, and movie two which has a pre-loader starts loading, etc, etc.

       

      Does this make sense, or is there a better way to present four individual movies on one html web page?

        • 1. Re: Can I have multiple individual/independent  Flash movies load in sequence?
          RossRitchey Level 4

          I have done something like this in the past.

           

          What I did was to create 1 flash movie that loads the other 4.  It loads them simultaneously, displaying a preloader.  When the first is fully loaded it starts playing, while the other 3 continue loading.  When the first one finishes, the second one starts playing, unless it isn't finished loading, at which point you go back to the preloader.

           

          When I did this, it was a quick-n-dirty solution - so the code can DEFINATELY be improved upon.  But here is the general gist of the technique.

           

          this.createClassObject(mx.controls.Loader, "myVidO", 8);

          this.createClassObject(mx.controls.Loader, "myVidT", 7);

          this.createClassObject(mx.controls.Loader, "myVidTT", 6);

          this.createClassObject(mx.controls.ProgressBar, "myPBO", 4, {source: "myVidO"});

          this.createClassObject(mx.controls.ProgressBar, "myPBT", 3, {source: "myVidT"});

          this.createClassObject(mx.controls.ProgressBar, "myPBTT", 2, {source: "myVidTT"});

          this.createTextField("chgParts", 10, 600, 5.735000E+002, 200, 1.850000E+001);

          this.createTextField("returnToMenu", 20, 10, 5.735000E+002, 300, 1.850000E+001);

          returnToMenu.type = "dynamic";

          returnToMenu.border = false;

          returnToMenu.html = true;

          returnToMenu.selectable = false;

          returnToMenu.align = "left";

          returnToMenu.htmlText = "<font face=\'Verdana\' size=\'12px\' color=\'#302E99\'><b><a href=\'asfunction:gotoMenu\'>Return To Menu</a>";

          chgParts.type = "dynamic";

          chgParts.border = false;

          chgParts.html = true;

          chgParts.selectable = false;

          chgParts.align = "right";

          myVidO.scaleContent = false;

          myVidT.scaleContent = false;

          myVidTT.scaleContent = false;

          myVidO.setSize(800, 600);

          myVidO.move(0, 0);

          myVidO.visible = false;

          myVidT.setSize(800, 600);

          myVidT.move(0, 0);

          myVidT.visible = false;

          myVidTT.setSize(800, 600);

          myVidTT.move(0, 0);

          myVidTT.visible = false;

          myPBO.setSize(500, 30);

          myPBO.move(100, 1.851000E+002);

          myPBT.setSize(500, 30);

          myPBT.move(100, 2.317000E+002);

          myPBTT.setSize(500, 30);

          myPBTT.move(100, 2.784000E+002);

          var loaderListener = new Object();

          var mv1C = new Object();

          var mv2C = new Object();

          var mv3C = new Object();

          var mv4C = new Object();

          var curPlay = new String("mayland1.swf");

          var ntp = new Number(1);

          var ntpS = new String("O");

          var arr = new Array(null, false, false, false, false);

           

          function switchPlaying(which)

          {

              myVidO.visible = myVidT.visible = myVidTT.visible = false;

              myVidO.content.gotoAndStop(1);

              myVidT.content.gotoAndStop(1);

              myVidTT.content.gotoAndStop(1);

              if (which != undefined)

              {

                  ntp = Number(which);

              } // end if

              switch (ntp)

              {

                  case 1:

                  {

                      ntpS = "O";

                      chgParts.htmlText = "<font face=\'Verdana\' size=\'12px\' color=\'#302E99\'><b><a href=\'asfunction:switchPlaying,2\'>Part 2</a>  |  <a href=\'asfunction:switchPlaying,3\'>Part 3</a>";

                      break;

                  }

                  case 2:

                  {

                      ntpS = "T";

                      chgParts.htmlText = "<font face=\'Verdana\' size=\'12px\' color=\'#302E99\'><b><a href=\'asfunction:switchPlaying,1\'>Part 1</a>  |  <a href=\'asfunction:switchPlaying,3\'>Part 3</a>";

                      break;

                  }

                  case 3:

                  {

                      ntpS = "TT";

                      chgParts.htmlText = "<font face=\'Verdana\' size=\'12px\' color=\'#302E99\'><b><a href=\'asfunction:switchPlaying,1\'>Part 1</a>  |  <a href=\'asfunction:switchPlaying,2\'>Part 2</a>";

                      break;

                  }

              } // End of switch

              var _loc2 = new String("myVid" + ntpS);

              if (arr[ntp] == true)

              {

                  _root[_loc2].visible = true;

                  _root[_loc2].content.play();

                  ++ntp;

              }

              else if (_root[_loc2].contentPath == undefined)

              {

                  var _loc3 = new String("mayland1.swf");

                  _root[_loc2].contentPath = _loc3;

              } // end else if

              curPlay = _root[_loc2].contentPath;

          } // End of the function

          function gotoMenu()

          {

              getURL("http://www.applied.com/corpcomm/public/videos/financial_08_1/index.html");

          } // End of the function

           

          loaderListener.progress = function (evt)

          {

              evt.target.content.gotoAndStop(1);

          };

          mv1C.complete = function (evt)

          {

              if (curPlay == myVidO.contentPath)

              {

                  myVidO.visible = true;

                  myVidO.content.play();

                  ntp = 2;

              } // end if

              arr[1] = true;

              if (arr[2] != true)

              {

                  myVidT.contentPath = "mayland2.swf";

              }

              else if (arr[3] != true)

              {

                  myVidTT.contentPath = "mayland3.swf";

              } // end else if

          };

          mv2C.complete = function (evt)

          {

              trace ("2 done");

              if (curPlay == myVidT.contentPath)

              {

                  myVidT.visible = true;

                  myVidT.content.play();

                  ntp = 3;

              } // end if

              arr[2] = true;

              if (arr[1] != true)

              {

                  myVidO.contentPath = "mayland1.swf";

              }

              else if (arr[3] != true)

              {

                  myVidTT.contentPath = "mayland3.swf";

              } // end else if

          };

          mv3C.complete = function (evt)

          {

              trace ("3 done");

              if (curPlay == myVidTT.contentPath)

              {

                  myVidTT.visible = true;

                  myVidTT.content.play();

                  ntp = 4;

              } // end if

              arr[3] = true;

              if (arr[1] != true)

              {

                  myVidO.contentPath = "mayland1.swf";

              }

              else if (arr[2] != true)

              {

                  myVidT.contentPath = "mayland2.swf";

              } // end else if

          };

          myVidO.addEventListener("progress", loaderListener);

          myVidO.addEventListener("complete", mv1C);

          myVidT.addEventListener("progress", loaderListener);

          myVidT.addEventListener("complete", mv2C);

          myVidTT.addEventListener("progress", loaderListener);

          myVidTT.addEventListener("complete", mv3C);

          switchPlaying(1);

           

          1. Create some Loader components (in this case, I used 3)

          2. Create progress bars to track the loads

          3. Watch for the complete event on all 3. - On complete, check if it is the one that is supposed to be playing, and play it if it is, otherwise let it be.

          4. At the end of each play, tell it to move on to the next one.

           

          Like I said - its AS2, and it is down-n-dirty.  (It also happens to be code from a decompiler, because I could only track down the SWF on quick notice.  I would have to go into my archives to get the FLA)  The code can definately be improved upon, but it presents the general course you could take to do this.