Copy link to clipboard
Copied
Well for example I have a deck of 52 cards, and I want the cards to be in different order everytime the game starts.
thanks
Copy link to clipboard
Copied
use the shuffle function to reorder arrays,
function shuffle(a:Array) {
var p:int;
var t:*;
var ivar:int;
for (ivar = a.length-1; ivar>=0; ivar--) {
p=Math.floor((ivar+1)*Math.random());
t = a[ivar];
a[ivar] = a
;
a
= t;
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now