Easy way to Randomize an Array.
Posted by Luracast on Jun 10, 2006 in Blog, Flash MX, Tips | 0 comments
Here is the sample code to shuffle the contents of an array
1 2 3 4 5 6 7 8 9 | // Here is a simple function for randomizing the array function randomsort(a, b) { return Math.random()>.5 ? -1 : 1; } //usage example var arr = [1, 2, 3, 4, 5]; arr.sort(randomsort); trace(arr); //traces 4,3,1,5,2 |
Archives
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Sep | ||||||
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 | |||
About Me
Multi-platform (desktop, mobile, devices etc) and web application development consultant focusing on flash platform
Tags
AcionScript
ActionScript
ActionScript1
ActionScript3
ActionScript Utility
Application
Applications
Arul Blog
AS1
AS3
Bug Fixing
Code
Code developer
Code PHP
Content
Content Development
Developer
Development Tools
Development Utility
Flash
Flash-DB
Flash 5
Flash Coders
Flash Communication Server
Flash Developer
Flash Development
Flash Framework
Flash JavaScript API
Flash MX
Flash News
Flex
Framework
JSFL
Macromedia Flash
PHP
PHP Developer
RSS
RSS XML Feed
Simplified Flash Framework
SWF
Technical News
Tips
Web Applications
Web Development
XML
Recent Posts
Recent Comments
- Tahir Alvi on Webcam Motion Detection using AS3.
- Luracast on Restler
- RV on Restler
- RV on Restler
- RV on Restler


