Graphics Reference
In-Depth Information
private var _allowClick:Boolean = true;
public function
MemoryGame(cards:Array,cardBack:String=null,spread:int=10):
void{
var cardsLen:uint = cards.length;
for(var d:int=0; d
<
2; d++){
for(var e:int=0; e
<
cardsLen; e++){
_memoryCards.push(cards[e]);
}
}
_memoryCards.shuffle();
_numberOfCards = _memoryCards.length;
_cardPadding = spread;
_tempCardBack = cardBack==null ? null :
Class(getDefinitionByName(cardBack));
}
public function
deal(layoutType:String=GRID_LAYOUT,customCoordinates:Array=
null,rows:int=2):void{
var c:int;
switch(layoutType){
/*case YOUR_LAYOUT:
CREATE OTHER LAYOUTS HERE
"
gridLayout
"
is only an example name
but you could use something like
"
circleLayout
"
,
"
lineLayout
"
, etc.
Be sure to set the name as a public
const. For example: GRID_LAYOUT =
"
gridLayout
"
break;*/
case CUSTOM_LAYOUT:
if(customCoordinates == null ||
customCoordinates.length != _numberOfCards){
trace(
'
ERROR: When using layoutType
"
custom
"
, your customCoordinates array must contain twice
as many coordinates as your array of images.
'
);
trace(
"
If you have 4 images, you
must have 8 sets of coordinates.
"
);
}else{
for(c=0; c
<
_numberOfCards; c++){
buildCard(_memoryCards[c],customCoordinates[c].x,custom
Coordinates[c].y);
}
}
break;
case GRID_LAYOUT: