Solved

how do you shuffle an Array in AS3

Posted on 2008-10-22
3
2,901 Views
Last Modified: 2013-11-11
how do you shuffle an Array in AS3.
is it even possible with AS3?
0
Comment
Question by:greeneel
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 500 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:greeneel
ID: 22785226
thx alot
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
YouTube Link 10 353
Where to download Acrobat flash offline installer? 2 239
Adobe Flash Install via GPO - Remove Prior Versions From GPO? 1 156
Firefox fullscreen video lags 4 155
I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
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…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now