2 Replies Latest reply on Mar 28, 2007 6:41 PM by delta_6_niner

    simple non repeat randomiser

    delta_6_niner

      i have found a couple of posts on this forum that discuss various arrays,

      i'm not a programmer as such so dont understand ****....

      basically i would like to replace my existing code

      loadMovieNum("1.swf",1);


      with a randomiser that will load at a random
      any movie between 1.swf - 10.swf

      i need to define the file names because in
      another instance i wish to use the same
      randomiser but this time to play any movie
      between 11.swf - 20.swf

      PLEASE HELP !!

        • 1. Re: simple non repeat randomiser
          mclem
          you just need to use the Math.random() function and multiple it by your range of numbers and at to it the minimum, oh and of course round or floor as the case may be.

          would be something like this:
          var randomMax:Number = 10;
          var randomMin:Number = 1;
          var randomFileNum:Number = Math.floor(Math.random() * randomMax + randomMin);

          trace(randomFileNum); //will display from 1 to 10;

          replace the randomMin number with 11 and it will now display between 11 and 20;


          then put it all add the loadMovieNum function in
          loadMovieNum(randomFileNum + ".swf", 1);
          • 2. Re: simple non repeat randomiser
            delta_6_niner Level 1
            cool cool

            i think this is exactly what i needed !