can anyone please help me with this script? I’m trying to build a card game and I’m stuck here…
I’ve shuffled the cards randomly and I’m trying to show the cards repsresenting the decks values which range from 00 to 311 (00 meaning ace of a suit 01, the next card, 02 next and so on, 10, another suit, 20, another suit and 30 for the last suit)
I have tried from other examples and have achieved it naming the frames 1h, 1S, 1D, and 1C, but would like to understand the way to retrieve the index of the cards’ values, which I’ve acomplished with the ReturnIndexArray sort method.
What can be wrong here?
function init() {
deck = new Array();
createdeck(0);
delete count;
function createdeck(suit) {
createcard(suit, 0);
if (suit<3) {
createdeck(suit+1);
}
function createcard(suit, card) {
do {
var deckpos = Math.round(Math.random()47);
} while (deck[deckpos] != null);
deck[deckpos] = String(suit)+String(card);
count += 1;
if (card<11) {
createcard(suit, card+1);
}
}
}
}
init();
var indexArray:Array = deck.sortOn("", Array.RETURNINDEXEDARRAY);
trace(indexArray);
showcards = function () {
for (var i = 0; i<=52; i++) {
_root[“card+1”].gotoAndStop(indexArray);
}
};
showcards();