Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how do you shuffle an Array in AS3

Posted on 2008-10-22
3
Medium Priority
?
2,917 Views
Last Modified: 2013-11-11
how do you shuffle an Array in AS3.
is it even possible with AS3?
0
Comment
Question by:Eaddy Barnes
3 Comments
 
LVL 37

Expert Comment

by:CyanBlue
ID: 22783071
What do you mean by shuffle???

CyanBlue
0
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 2000 total points
ID: 22783201
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
 
LVL 11

Author Comment

by:Eaddy Barnes
ID: 22785226
thx alot
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question