Preventing the player from cheating

Players will always try to cheat. When making a game, don't expect people to respect any policy of playing.

We must prevent the player from continuing to pick tiles when the script is waiting to let him see the second tile he picked.

We need another instance variable, of a new type. Change class level variables and constants by coding this way:

// class level variables and constants
private var pickedTiles:Array = new Array();
private const NUMBER_OF_TILES:uint=20;
private var pauseGame:Timer;
private var canPick:Boolean=true;
// end of class level variables and constants

Boolean variables can only have a true or false value. canPick variable will decide whether the player can pick another tile or not. Initially, ...

Get Flash Game Development by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.