Game Development Reference
In-Depth Information
wordField.text = (_wordIndex) ? _wordIndex.
toString() : "" ;
wordField.mouseEnabled = false;
The constructor stores the letter passed in, sets up a notification
for when the tile is added to the display list, and toggles to the nor-
mal state or the blacked-out state. The init method sets up the text
fields and disables mouse interaction with them. To some, these
may seem like steps that could simply be accomplished in the con-
structor, but unfortunately, this is not the case. If you tried to move
This is a point of confusion for many people, but suffice it to say
that while we
same name to our text field instances on the Stage, Flash will link
the declared variable to the actual object. However, this step does
not take place until after the constructor has completed, so the
next best time to run these commands is when the tile is added to
the Stage and ready to use.
Now that we have the class defining a tile created, we need to
see the display object to which it will be linked. Open up the
CrosswordPuzzle.fla file from the Chapter 10 examples folder. In
the Library, you will find a symbol called CrosswordTile. If you
open it, you will see the two text fields (with the names of the vari-
ables in the class) and the two frames showing the different states
that a tile can use. If you bring up the properties panel for the
ve declared thattherewillbetwotextfields,we
Figure 10.2 The CrosswordTile
symbol is made up of a square
and two text fields.
Figure 10.3
The CrosswordTile symbol is now linked to its class.
Search Nedrilad ::

Custom Search