fluke12
09-13-2009, 11:23 PM
I'm trying to write a card game. the code in question is below. I've set arrays for suit, number and number of card in the deck (aka, there is only one Ace of Spades in deck). The var "card" is used later to attach a movieclip and load the image on the stage.
theoretically, the second trace, should give you a number. My suspicion is that it becomes a string and doesn't trace the actual array value.
Any ideas on how to make this actually pull the array value?
Stop;
//setting names, point value and suits for all of the cards for images
card_name = new Array("2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A");
card_suit = new Array("Hearts", "Diamonds", "Spades", "Clubs");
Hearts_count = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
Spades_count = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
Diamonds_count = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
Clubs_count = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
//object to declare a card
cardObject = {number:card_name, suit:card_suit};
//random variables to get a random card
randomCardName = Math.floor(Math.random()*(13));
randomCardSuit = Math.floor(Math.random()*(4));
//gets specific card
card = String(cardObject.number[randomCardName]+"_"+cardObject.suit[randomCardSuit]);
card2=(cardObject.suit[randomCardSuit]+"_count["+[randomCardName]+"]");
trace(card)
trace(card2)
theoretically, the second trace, should give you a number. My suspicion is that it becomes a string and doesn't trace the actual array value.
Any ideas on how to make this actually pull the array value?
Stop;
//setting names, point value and suits for all of the cards for images
card_name = new Array("2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A");
card_suit = new Array("Hearts", "Diamonds", "Spades", "Clubs");
Hearts_count = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
Spades_count = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
Diamonds_count = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
Clubs_count = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
//object to declare a card
cardObject = {number:card_name, suit:card_suit};
//random variables to get a random card
randomCardName = Math.floor(Math.random()*(13));
randomCardSuit = Math.floor(Math.random()*(4));
//gets specific card
card = String(cardObject.number[randomCardName]+"_"+cardObject.suit[randomCardSuit]);
card2=(cardObject.suit[randomCardSuit]+"_count["+[randomCardName]+"]");
trace(card)
trace(card2)