Solved

how do you shuffle an Array in AS3

Posted on 2008-10-22
3
2,905 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 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:Eaddy Barnes
ID: 22785226
thx alot
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Install adobe flash plugin for Firefox win 7 9 70
Download Adobe Flash Player 6 67
Adobe Indesign CS6 4 131
Can't enable Flash on Chrome 32 Windows 7 any more 2 29
This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
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.
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.

820 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