3 Replies Latest reply on Jun 14, 2010 8:25 PM by kglad

    Multiple MovieClips Loading SWF From Same Array (Posted Code)

    Vorpal11

      Hey there,

       

      I'm currently working on a project that has eight separate movieclips (for loading content) on separate layers.  I have placed code in these mc's to randomly draw from the same array of 61 different swf's.  Each mc randomizes the array just fine, but here's the problem.  The code works great for one instance, but as soon as I add the code (including renaming) to the other mc's, the swf won't load/play.  I am not getting an compiler errors, and am kinda stuck as to what the problem may be.  Here's an example of the code I'm using.  It is the same for each mc, except I'm renaming the variables as well as the instances for each mc.  Thanks for any suggestions.

       

      Mike

       

      //filename = new Array("screen1.swf","screen2.swf","screen3.swf","screen4.swf","screen5.swf","screen6.swf" ,"screen7.swf","screen8.swf","screen9.swf","screen10.swf","screen11.swf","screen12.swf","s creen13.swf","screen14.swf","screen15.swf","screen16.swf","screen17.swf","screen18.swf","s creen19.swf","screen20.swf","screen21.swf","screen22.swf","screen23.swf","screen24.swf","s creen25.swf","screen26.swf","screen27.swf","screen28.swf","screen29.swf","screen30.swf","s creen31.swf","screen32.swf","screen33.swf","screen34.swf","screen35.swf","screen36.swf","s creen37.swf","screen38.swf","screen39.swf","screen40.swf","screen41.swf","screen42.swf","s creen43.swf","screen44.swf","screen45.swf","screen46.swf","screen47.swf","screen48.swf","s creen49.swf","screen50.swf","screen51.swf","screen52.swf","screen53.swf","screen54.swf","s creen55.swf","screen56.swf","screen57.swf","screen58.swf","screen59.swf","screen60.swf","s creen61.swf");
      //i = filename.length;
      //k=random(i)
      //_root.movieTarget.loadMovie(filename[k]);
      //movieTarget._xscale=80;
      //movieTarget._yscale=80;

       

      var fileNames:Array = ["screen1.swf","screen2.swf","screen3.swf","screen4.swf","screen5.swf","screen6.swf","scr een7.swf","screen8.swf","screen9.swf","screen10.swf","screen11.swf","screen12.swf","screen 13.swf","screen14.swf","screen15.swf","screen16.swf","screen17.swf","screen18.swf","screen 19.swf","screen20.swf","screen21.swf","screen22.swf","screen23.swf","screen24.swf","screen 25.swf","screen26.swf","screen27.swf","screen28.swf","screen29.swf","screen30.swf","screen 31.swf","screen32.swf","screen33.swf","screen34.swf","screen35.swf","screen36.swf","screen 37.swf","screen38.swf","screen39.swf","screen40.swf","screen41.swf","screen42.swf","screen 43.swf","screen44.swf","screen45.swf","screen46.swf","screen47.swf","screen48.swf","screen 49.swf","screen50.swf","screen51.swf","screen52.swf","screen53.swf","screen54.swf","screen 55.swf","screen56.swf","screen57.swf","screen58.swf","screen59.swf","screen60.swf","screen 61.swf"]
      fileNames.sort(function () {
          return Math.round(Math.random());
      });
      trace("Random array: " + fileNames);

       

      var currentMovieNum:Number = 0    ;

       

      this.createEmptyMovieClip("container", _root.getNextHighestDepth());
      var mcl:MovieClipLoader = new MovieClipLoader();
      var mclListener:Object = new Object();
      mcl.addListener(mclListener);
      mclListener.onLoadInit = function(movieTarget:MovieClip) {
          trace("Preparing to play: " + fileNames[currentMovieNum]);
      };
      movieTarget.loadClip(fileNames[currentMovieNum], container);
      movieTarget._xscale=80;
      movieTarget._yscale=80;

       

      this.onEnterFrame = function() {
          if (currentMovieNum == fileNames.length) {
              currentMovieNum = 0;
          } else {
              if (movieTarget._currentframe == movieTarget._totalframes) {
                  mcl.loadClip(fileNames[currentMovieNum], movieTarget);
                  currentMovieNum++;
              }
          }
      };

        • 1. Re: Multiple MovieClips Loading SWF From Same Array (Posted Code)
          kglad Adobe Community Professional & MVP

          the first problems i see:

           

          1.  your array randomization isn't much of a randomizer.

           

          2.  movieTarget doesn't appear to be defined (outside your onLoadInit).

           

          3.  loadClip() is an mcl method.

          • 2. Re: Multiple MovieClips Loading SWF From Same Array (Posted Code)
            Vorpal11 Level 1

            Thanks for taking a look at this.  The randomizer seems to work just fine, as here is a sample output from the trace:

             

            Random array: screen47.swf,screen2.swf,screen57.swf,screen21.swf,screen9.swf,screen49.swf,screen36.swf, screen17.swf,screen6.swf,screen59.swf,screen15.swf,screen12.swf,screen33.swf,screen25.swf, screen42.swf,screen22.swf,screen24.swf,screen40.swf,screen11.swf,screen19.swf,screen32.swf ,screen35.swf,screen7.swf,screen39.swf,screen23.swf,screen4.swf,screen1.swf,screen48.swf,s creen31.swf,screen45.swf,screen29.swf,screen18.swf,screen51.swf,screen14.swf,screen34.swf, screen10.swf,screen38.swf,screen26.swf,screen16.swf,screen13.swf,screen55.swf,screen37.swf ,screen44.swf,screen61.swf,screen43.swf,screen20.swf,screen28.swf,screen30.swf,screen56.sw f,screen50.swf,screen54.swf,screen53.swf,screen46.swf,screen58.swf,screen41.swf,screen8.sw f,screen5.swf,screen52.swf,screen3.swf,screen60.swf,screen27.swf

             

            Might you be able to lead me down a better path?  I'm currently unable to get this to function for multiple symbols.  The previous is the code that I've placed on the first keyframe of a movieclip with an instance name of movieTarget.  Works swimmingly for one, but once the code is placed on the other symbols on different layers, it seems to only work on the lowest layer in the project.

             

            M

            • 3. Re: Multiple MovieClips Loading SWF From Same Array (Posted Code)
              kglad Adobe Community Professional & MVP

              that's surprising but looks random enough.  and a test shows it's pretty good.

               

              the other comments, though are valid and you need to fix those problems.