• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2928
  • Last Modified:

how do you shuffle an Array in AS3

how do you shuffle an Array in AS3.
is it even possible with AS3?
0
Eaddy Barnes
Asked:
Eaddy Barnes
1 Solution
 
CyanBlueCommented:
What do you mean by shuffle???

CyanBlue
0
 
Aneesh ChopraCommented:
I think this what you want,


following code works for both AS2 and AS3 without any change..
var myArray = [0,1,2,3,4,5,6,7,8,9];
 
trace("before:"+myArray);
myArray = myArray.sort(Randomise);	
trace("after:"+myArray);
 
function Randomise(a, b):Number {
	var num:Number = Math.round(Math.random()*2)-1;
	return num;
}

Open in new window

0
 
Eaddy BarnesITAuthor Commented:
thx alot
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now