Skip navigation
Currently Being Moderated

Tracing a spliced array more than once

Jul 12, 2012 2:27 AM

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);



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?

  • Currently Being Moderated
    Jul 12, 2012 4:28 AM   in reply to witherton

    I don't see how that does what you say you want it to do (returns the contents of an array in random order)... it is not randomizing the order of the array.  It is removing things from it.


    What do you have that continually calls the functions or that calls for retracing within the function?

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points