1 Reply Latest reply: Jul 12, 2012 4:28 AM by Ned Murphy RSS

    Tracing a spliced array more than once

    witherton

      I am trying to create a randomizing  function that returns the contents of an array once in a random order. I have the following array:

       

      var randomArray:Array=["one","two","three"]

       

      and I have the following code inside the function:

       

      var r:int=Math.floor(Math.random()*randomArray.length);

      trace(randomArray.splice(r,1));

       

      It traces the array once through randomly, but stops when it gets to the end of the array. I suppose that is due to the splice command. What do I need to do to have the function constantly call a new random ordering, instead of stopping once it runs through the first trace?