Game Development Reference
In-Depth Information
9. Finally, you need to give the input text field an instance name. Make sure that it's still selected
and enter the name input in the Instance name box of the Properties panel. (Again, give this the
instance name input_txt if you want to activate code hinting in the ActionScript editor window.)
The last thing that you might want to do is delete the sample text that you used to size the fields cor-
rectly, but you don't really have to do this. This sample text will be overwritten by new text that you'll
create directly in the program.
Strangely enough, even though input text fields allow the users to input text, you can
actually insert text into them with programming code, just as you can with dynamic
text. You can, therefore, think of input text fields as dynamic text fields with the added
bonus that text can be entered into them if you need to. You'll see how this works
when you start adding the code to the program in the pages ahead.
A little more about fonts and text fields
As you can see, there are an awful lot of other options you can add in the text Properties panel.
Feel free to experiment with them. There are a few though, that are particularly important for game
developers:
Anti-aliasing. The Anti-alias option is in the Character pane. When text characters curve, their edges
can appear blocky and jagged, which is an effect known as pixelation . Anti-aliasing is a style of ren-
dering text that smoothes out pixelated edges. The one big problem with anti-aliasing, however, is that
it takes a considerable amount of processing power to smooth out text.
Fonts are complex vector shapes, which are plotted mathematically by the CPU on the screen by draw-
ing lines between points. The smoother the font appears, the more vectors have to be plotted, and the
harder the CPU has to work. Any power that the CPU spends plotting vectors for fonts is less power it
has to make the animations, videos, and other effects in your games run smoothly. It detracts from the
almighty performance, which has the final say in game development. The Flash Player has improved
considerably in the text-rendering department over the years, but earlier versions of the Player were
notorious for expending up to half of the available CPU power just to render text. Game developers
are therefore very sensitive to this issue!
You probably won't notice this performance hit in the little games you'll be building initially, but if
you have anti-aliased text on the stage and you start piling on lots of complex animations, your games
will start to stutter and drag. The first thing you should do, then, is turn off text anti-aliasing. Flash
provides a few different options you can use to do this:
Device fonts : These are fonts that are installed on your computer, which means that Flash
doesn't have to do any work to draw them. It also means that it doesn't need to include font
outlines as extra data in the SWF file, so file sizes will be smaller. (More on font outlines soon!)
Device fonts are also not anti-aliased, so they're very fast for the CPU to display. The only draw-
back (and a potential deal breaker if you really care about how the fonts in your games look)
is that you're limited to only three font styles: _sans , _serif , and _typewriter . (All device font
names are preceded with an underscore.) _sans is similar to Arial, _serif is similar to Times New
 
Search Nedrilad ::




Custom Search