Game Development Reference
the text Properties panel can be accessed and changed with code. But there are also lots more that can
be accessed only with code.
This topic doesn't go into these options in any depth, but if you're curious about what's
available, take a peek at the chapter “Working with Text” in Adobe's Programming
Adobe ActionScript 3.0 manual (dppl6++dahl*]`k^a*_ki+aj[QO+=_pekjO_nelp+/*,[
Lnkcn]iiejc=O/+). To whet your appetite a bit, I included a few of these options in the
The first thing is to make the background of the input text field a light gray color:
^]_gcnkqj`?khkn is a property of the PatpBeah` class. The color is represented by a hexadecimal
color code, and ,tBB?????? is the hexadecimal code for light gray. As long as you know the hexadeci-
mal code, you can use any color you like. (A web search for “hexadecimal color chart” will bring up
many examples of colors and their matching hexadecimal codes.)
The next line uses the naopne_p property to prevent the input text field from accepting any characters
other than numbers:
The naopne_p property limits the characters you can enter to whatever letters or numbers are inside
the quotes. For example, if you want to restrict the text field to only the uppercase letters A, B, and C,
you can write a directive that looks like this:
You can restrict a range of numbers or letters by separating the first character in the range from the
last character with a dash. Here are some examples:
To allow only the uppercase letters from M to O, use I)O”.
To allow all uppercase letters, use =)Z”.
To restrict input to just lowercase letters, use ])z”.
To allow only uppercase and lowercase letters, use =)V])z”.
Your life as a programmer will often be improved by restricting certain types of input because if a user
enters something that your program doesn't know how deal with, the whole program could stop
The last thing is to create the blinking cursor in the input text field. Use the following line of code:
When an object on the stage, such as a button or a text field, has been selected by the user, it's said to
have focus . When input text fields have focus, a blinking cursor appears, and whatever the user types
is automatically entered into it. bk_qo is a property of the built-in Op]ca class, which is at the root of