2 Replies Latest reply on Apr 4, 2010 6:33 PM by rsquaredpgh

    Load Random Swfs from Array & Navigation

    rsquaredpgh

      I don't think I'm as familiar with arrays as I need to be to complete the following project - I've read about 60 posts and no one seems to be doing exactly what I am. Here's what I need to do:

       

      From a main swf (home.swf), I need to load 7 consecutive swfs in random order, (movie01.swf, movie02.swf, etc) from an array, into level 1. I need all seven to play without repeating, then repeat them in the same order in a loop.

       

      But I ALSO need the user to be able to navigate through the swfs by using next or previous buttons (or by selecting individually 1-7, but that may be asking too much from my limited knowledge).

       

      Here is the code I'm using to generate a random ordered array:

       

      var fileNames :Array=new Array("movie01.swf","movie02.swf","movie03.swf");
      shuffle = function (targetArray) {
      for (i=0; i<targetArray.length; i++) {
      var tmp = targetArray[i];
      var randomNum = random(targetArray.length);
      targetArray[i] = targetArray[randomNum];
      targetArray[randomNum] = tmp;
      }
      };
      shuffle(fileNames )
      trace(fileNames )

       

      I assume from here I can load the swfs from fileNames [0]. I'm way out of my depth so the rest is a mystery to me. ANY help on this would be greatly appreciated.

        • 1. Re: Load Random Swfs from Array & Navigation
          Ned Murphy Adobe Community Professional & MVP

          The randomizer looks like it works okay.

           

          If these movies are supposed to load such that one finishes playing before the next is loaded, you'll need to create some mechanism for triggering that to happen... either adding code to the movies that you load to tell the main movie to load the next, or to have the main movie keep track of the _currentframe versus _totalframes if the loaded movies are purely timeline animations and trigger the next loading when those two values are equal.

           

          As far as loading tthings goes, you have a couple of choices... use loadMovie() or use MovieClipLoader.loadClip()... the latter is better and especially more useful if you need to keep track of the loading process.

           

          So what you oughta do is take a small bite and see what it takes to load a single movie.  Then figure out how to expand that into a function that pulls in an array element to load.  See what you can do, and if you have a problem, show the code that isn't working and someone will likely help iron things out.

          • 2. Re: Load Random Swfs from Array & Navigation
            rsquaredpgh Level 1

            Thanks. I'll see what I can come up with and come back.

             

            Date: Sun, 4 Apr 2010 16:29:22 -0600

            From: forums@adobe.com

            To: rsquaredpgh@hotmail.com

            Subject: Load Random Swfs from Array &amp; Navigation

             

            The randomizer looks like it works okay.

             

            If these movies are supposed to load such that one finishes playing before the next is loaded, you'll need to create some mechanism for triggering that to happen... either adding code to the movies that you load to tell the main movie to load the next, or to have the main movie keep track of the _currentframe versus _totalframes if the loaded movies are purely timeline animations and trigger the next loading when those two values are equal.

             

            As far as loading tthings goes, you have a couple of choices... use loadMovie() or use MovieClipLoader.loadClip()... the latter is better and especially more useful if you need to keep track of the loading process.

             

            So what you oughta do is take a small bite and see what it takes to load a single movie.  Then figure out how to expand that into a function that pulls in an array element to load.  See what you can do, and if you have a problem, show the code that isn't working and someone will likely help iron things out.

            >