Scripting the Game


The Hangman game consists of a series of rounds, corresponding to the number of available words to guess. In each round, the computer randomly chooses a word and generates slots as placeholders for the letters. The user attempts to guess the word one letter at a time. For each right guess, the letter appears. For each wrong guess, a piece of the alien character appears. After six wrong guesses, the alien character is completed, does a little animation for us, and the round is over. The score for each round appears on the screen.

The three primary states to the game are the setup, user input, and interpretation of the user input. Most of the code for this aspect of the game is located in the class files located in the ch31 folder of this book's CD-ROM.

The game has an additional feature: The username and his or her score are saved on the local machine, and the data is available the next time the user plays the game. Most of the code for this feature is located in the GameModel class. However, we cover this feature last.

Tip 

The SharedObject class enables you to save data locally, similarly to the way a cookie saves data in a Web browser. This feature is only available for Flash Player 6 and higher movies.




Macromedia Flash 8 Bible
Macromedia Flash8 Bible
ISBN: 0471746762
EAN: 2147483647
Year: 2006
Pages: 395

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net