Solved

how do you shuffle an Array in AS3

Posted on 2008-10-22
3
2,910 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

627 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