Game Development Reference
In-Depth Information
Figure 10.4 The CrosswordClue
class extends Sprite, even
though it says MovieClip in the
symbol properties.
other than system fonts) are clumsily handled through ActionScript
and require more hassle than simply creating a symbol with a
TextField object inside it and linking it to a class. In fact, spawning
a new TextField from scratch in code and assigning it for format-
ting objects and positioning is as much or more code than the
class we just created.
In the CrosswordPuzzle.fla file, you
ll find a symbol in the
library named CrosswordClue, and it has the single TextField
named clueText. It is set to export using the same class name and
is extending from the base class Sprite. You may have some cogni-
tive dissonance when you see that the base class field says Sprite,
but the type still says MovieClip. This has to do with the way the
Flash authoring environment handles timeline-based elements and
is a holdover from older versions, presumably for consistency. To
help the confusion (or perhaps add to it), Flash now color-codes
Sprites in the Library as green instead of the MovieClip blue. Don
'
'
t
dwell too hard on it
s a quirk of Flash and while annoying does
not cause any real problems.
it
'
The CrosswordPuzzle Class
With the individual tiles and the clue field ready to be used, it
'
s time
to set up the core CrosswordPuzzle engine. Unlike the two previous
components, we will not link this class to a symbol in the library.
Because crossword puzzles can be any number of sizes, having any
type of fixed layout defined in a symbol would make the class too rigid
to deal with. Say, for instance, you wanted to support multiple dimen-
sions of puzzles in a single game; if you tied the class to specific sym-
bols, you would need to do so as the base class and have multiple
Search Nedrilad ::




Custom Search