Game Development Reference
In-Depth Information
return false;
public function deactivate() {
public function activate() {
When a user enters a keyboard input on a tile, it will call
setAnswer . This method is a normal public function that another
class can call, but it accepts a KeyboardEvent as its parameter like
an event handler. This allows another method elsewhere to pass
along the received keyboard event for evaluation without having
this method attached to a listener. Once it checks to see whether
the key pressed is an alphabetic character or backspace, it updates
itself accordingly. It does not validate the answer further, but it
does return true if a letter was entered and false if any other key
was pressed. The activate and deactivate methods simply toggle
between two different frames to show the tile as a usable square or
a blank.
The constructor for the class will build the tile based on the
character it is given to display. Remember how we denoted a
blanked-out space with an underscore in the XML. We
ll define a
constant property named EMPTY for this character, so that we can
easily reference it (and even change it later if needed).
static public const EMPTY:String = " _ " ;
public function CrosswordTile(letter:String = EMPTY) {
this.letter = letter;
addEventListener(Event.ADDED_TO_STAGE, init, false, 0,
if (letter == EMPTY) {
} else {
protected function init(e:Event) : void {
if (letterField) {
letterField.text = "" ;
letterField.mouseEnabled = false;
if (wordField) {
Search Nedrilad ::

Custom Search