Controlling Text with ActionScript

If you're used to using a word processor, it probably seems pretty natural to format your text with menus and the Properties panel. After all, they aren't that much different from Microsoft Word menus and dialog boxes. On the other hand, if you want to make major changes to text on the fly, or if you want to format text with HTML (hypertext markup language) or CSS (Cascading Style Sheets), you have to use ActionScript to produce your text. You saw some text and ActionScript examples in Chapter 12 (Strings). You'll find more here. First, the elementary basics, which begin with string theory.

ActionScript Text: String Theory

Flash has lots of text containers, like TLF editable and Classic dynamic text, and then there are the components: Label, TextArea, and TextInput. All of these textdisplaying tools use the String data type (Strings). As far as ActionScript is concerned, a string is similar to an array, in that it's a list of characters. The list can be a single character or hundreds of characters. Each character is in a specific position in the list—its index number (Boolean). Arrays and strings both begin counting at position zero (0). So if the string is "Stutz Modern Motorcars" that capital S is at position 0.

Note

Strings are common to most programming languages, and there are loads of books that explain how to perform string manipulation magic. Most Flash programs don't require such trickery. This chapter explains some of the most common techniques ...

Get Flash CS5: The Missing Manual now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.