Graphics Reference
In-Depth Information
import com.flashadbook.engines.MemoryGame;
import com.flashadbook.events.MemoryGameEvent;
public class MemoryGameSample extends MovieClip{
private var _memoryGame:MemoryGame;
private var _gameCards:Array = new
Array("cardFace1","cardFace2","cardFace3","cardFace4");
/*The x and y values for the rows and columns of
the custom layout of the cards
The visual layout looks like this:
card card card
card card
card card card*/
private var _row1:int = 5;
private var _row2:int = _row1 + 172;
private var _row3:int = _row2 + 172;
private var _col1:int = 5;
private var _col2:int = _col1 + 136;
private var _col3:int = _col2 + 136;
//The array used to place the cards
private var _coordArr:Array = new
Array({x:_col1,y:_row1},{x:_col1,y:_row2},{x:_col1,y:_row3},
{x:_col2,y:_row1},{x:_col2,y:_row3},{x:_col3,y:_row1},{x:_col3,
y:_row2},{x:_col3,y:_row3});
public function MemoryGameSample() {
newGame(_gameCards,_coordArr);
}
private function
newGame(cardsToUse:Array,locationArr:Array=null):void{
_memoryGame = new
MemoryGame(cardsToUse,"cardBack");
addChild(_memoryGame);
//Deal the cards
_memoryGame.deal(_memoryGame.CUSTOM_LAYOUT,locationArr);
_memoryGame.addEventListener(MemoryGameEvent.CORRECT_MATCH,
correctMatchHandler,false,0,true);
_memoryGame.addEventListener(MemoryGameEvent.INCORRECT_MATCH,
incorrectMatchHandler,false,0,true);
_memoryGame.addEventListener(MemoryGameEvent.GAME_COMPLETE,
gameCompleteHandler,false,0,true);
}
private function
correctMatchHandler(e:MemoryGameEvent):void{
Search WWH ::




Custom Search