2 Replies Latest reply on Sep 7, 2006 5:55 AM by injpix

    random array

    Dz(00)
      hi,
      I have this script:

      var let = new Array();
      let[0] = "E";
      let[1] = "X";
      let[2] = "P";
      let[3] = "R";
      let[4] = "I";
      let[5] = "N";
      let[6] = "C";
      let[7] = "T";
      let[8] = "H";
      let[9] = "D";
      let[10] = "F";
      let[11] = "B";
      let[12] = "W";
      let[13] = "S";
      let[14] = "A";
      let[15] = "G";
      let[16] = "L";
      let[17] = "Y";
      let[18] = "O";
      let[19] = "U";
      L1.onEnterFrame = function() {
      L1.shuffle = (let[random(let.length)]);
      if (L1.shuffle == "E") {
      delete this.onEnterFrame;
      }
      };

      It currently selects a random letter from the array until it reaches the 'correct' letter, in this case being the letter "E".
      But I don't want to select from the entire array, just from a range, say let[10] to let[15].

      How would I do this? thanks in advance...
        • 1. Re: random array
          maybe you could declare another small array copy let[10]-let[15] to there and run random function?
          • 2. Re: random array
            injpix Level 3
            As arkhon13 suggested create, “another small array copy”, this is an ideal way of doing it depending on what it is you are doing to this array. I recently created a complex class that did exactly this however, I was just having the user traversing thru the elements and not editing them in this “another small array”. The code below will do what you have requested.