Game Development Reference
In-Depth Information
op]npIaoo]ca9E]ipdejgejckb]jqi^an^apsaaj-]j`-,,7
iuopanuJqi^an91,7
++Ejepe]hevapatpbeah`o
kqplqp*patp9op]npIaoo]ca7
ejlqp*patp97
ejlqp*^]_gcnkqj`?khkn9,tBB??????7
ejlqp*naopne_p9,)57
op]ca*bk_qo9ejlqp7
y
2. Save the I]ej*]o file and test the program. You should now see a much more easy-to-use
input text field with a gray background and a blinking cursor, as shown in Figure 5-12.
Figure 5-12. The input text field has a gray background and
a blinking cursor. It prevents letters from being entered.
3. Try entering some text other than numbers. Ha! You can't do it, can you?
Text field objects belong to AS3.0's PatpBeah` class. You can actually create text fields out of pure
code as long as you import the PatpBeah` class into your program, along with your other import
directives, like this:
eilknpbh]od*patp*&7
The PatpBeah` class is part of Flash's patp package, which contains many useful text-related classes.
To import all the classes of a given package, use an asterisk instead of a specific class name. With all
classes in the patp package imported, you can create a text field object and then display, size, format,
and position it on the stage. All it takes are a few lines of code in your constructor or ejep method
that might look something like this:
r]npatpBeah`K^fa_p6PatpBeah`9jasPatpBeah`$%7
patpBeah`K^fa_p*patp9Daucquo7
patpBeah`K^fa_p*daecdp9/,7
patpBeah`K^fa_p*se`pd9-,,7
patpBeah`K^fa_p*t9./,7
patpBeah`K^fa_p*u9.,,7
]``?deh`$patpBeah`K^fa_p%7
Interesting! But you didn't do this in the program. Instead, you used Flash's drawing tools to create,
format, and position the text fields; Flash automatically imported all the classes in the patp package
in the background. This is great because it means that the input and output text fields can use all the
formatting options available to these classes. In fact, all the options you assigned the text fields in
 
Search Nedrilad ::




Custom Search