Text Fields


As you might expect from a program used to develop Web sites, Flash comes with some powerful tools to add text to your movies. By creating what is called a text field, you can easily add several kinds of text elements to your work. Text fields come in three types:

  • Static text. This is text that will be displayed and will never change. After you enter this text, it stays exactly as you entered it for the life of the text field. Most text is static text.

  • Dynamic text. This is text that can be changed over the life of the text field. Dynamic text is typically used to display dynamic information in a game. For example, a player's current score is one good use of a dynamic text field. The player's score changes as he completes tasks in the game, so the value displayed in the box must change. By using a variable, you can allow Flash to automatically update the contents of your dynamic text field when things in your game change. (You will learn about variables in Chapter 2, "Flash ActionScript.")

  • Input text. This is text that the user can change while playing your game. Many times the user needs to enter some information, such as his nickname. By creating an input text field, you can give him a place to type the information. In a similar way to dynamic text, input text is associated with a variable. When the user changes the text in the input text field, your program will know about it. That way, your script can monitor what the user has entered into the input text field and act appropriately. A good example of an input text field in a game is a form for the user to enter his nickname so that you can post his name and score on a highscore board.

Because both dynamic and input text fields require the use of ActionScript and we have not covered any of that yet, I'm leaving an explanation of those types of text fields until we are ready for them. For now, let's look at the creation of static text fields.

Tip  

Text in Flash is normally anti-aliased, meaning that small fonts have a tendency to be a bit blurry. A new feature in Flash allows you to make text fields aliased by clicking the Alias text button while you have one or more text fields selected.




Macromedia Flash MX 2004 Game Programming
Macromedia Flash MX 2004 Game Programming (Premier Press Game Development)
ISBN: 1592000363
EAN: 2147483647
Year: 2004
Pages: 161

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