Let’s suppose that I have something like this:
dogs = new Array();
for (var i:int = 1; i <= 30; i++)
{
dogs.push(i);
}
This would produce 30 numbers in an array from 1-30. From there I wish to randomise the array.
function randomiseArray(a:*, b:*):int {
return 1-Math.floor(Math.random()*2.9999);
}
dogs.sort(randomiseArray);
trace(dogs);
Suppose now I wanted to use only the first 5 numbers of the results in another array - what would be the best way of doing this?
_thanks