Graphics Reference
In-Depth Information
/* The default GRID_LAYOUT places one
instance of each card in each row
The default GRID_LAYOUT uses 2 rows
and the number of columns is equal to the number of cards
passed in*/
for(var r:int=0; r < rows; r++){
for(c=0; c < _numberOfCards/rows;
c++){
var cardPos:int = c +
((_numberOfCards/rows)*r);
buildCard(_memoryCards[cardPos],(_frontSkin.width*c)+(_card
Padding*c),(_frontSkin.height*r)+(_cardPadding*r));
}
}
break;
}
}
// showCard draws a card to the game
private function
buildCard(cardName:String,cardX:int=-1,cardY:int=-1):void{
_tempCard =
Class(getDefinitionByName(cardName));
_frontBmd = new _tempCard(0,0);
_frontSkin = new Bitmap(_frontBmd);
_backBmd = _tempCardBack==null ? new
BitmapData(_frontSkin.width,_frontSkin.height,false,0xCCCCCC) :
new _tempCardBack(0,0);
_backSkin = new Bitmap(_backBmd);
var cardSprite:Sprite = new Sprite();
cardSprite.addChild(_frontSkin);
cardSprite.addChild(_backSkin);
cardSprite.x = cardX;
cardSprite.y = cardY;
cardSprite.buttonMode = true;
_cardSprite.addEventListener(MouseEvent.CLICK,showCard);
addChild(cardSprite);
}
// showCard completes the card flip and shows the
player what card they have chosen
private function showCard(e:MouseEvent):void{
if(!_allowClick){
return;
}
Search WWH ::




Custom Search