2 Replies Latest reply on May 4, 2007 10:43 AM by Steelers

    Prevent Consecutive Random Number Dups

    Steelers
      Hi. I'm generating a bunch of random numbers between 1 and 5 and need to prevent them from being the same back to back. I don't need a mutually exclusive array. Duplication is all right - just not back to back. So 1,3,4,3,5,3,1,3 is okay but 1,3,3 isn't. Here's my code:

      function insertRandomClip () {
      var clipID = Math.ceil(Math.random()*5);
      _root.attachMovie(clipID+"c", "tmp", 0, {_x:0, _y:0});
      }
      setInterval (insertRandomClip,500);

      Thanks for looking ...
      Paul