Chapter 17. Text, Styles, and Fonts

FEATURED CLASSES

  • flash.text.TextField

  • flash.text.TextFormat

  • flash.text.StyleSheet

  • flash.text.TextLineMetrics

  • flash.text.Font

  • flash.text.*

Text is an indispensable aspect of any application, and TextField is the base object for dealing with text anywhere in Flash Player. TextField handles both labels that display text and interactive text fields that a user can type into, like a form.

To display TextField objects, you'll add and remove them from the stage or parent object like any other DisplayObject. Because TextField extends InteractiveObject, it has methods to deal with mouse interaction, and many events it can throw, as well as many of the events I cover in Chapter 21, "Interactivity with the Mouse and Keyboard." Sizing, scaling, moving, and reparenting a TextField are all handled in the same way as any other DisplayObject.

Unique to TextField are methods and properties to control the appearance of text it contains. The formatting can be controlled by TextFormat objects, CSS styles, or a subset of HTML. Using the TextFormat class, you can set properties for the entire TextField or just for certain spans of characters. You'll also look at how to embed fonts and how to control the way those fonts appear using text smoothing properties.

With TextFields, you have a lot of control over the display of text in Flash Player. You can get even more control by using the Flash Text Engine and the Text Layout Framework, covered in the next chapter. In this chapter ...

Get ActionScript 3.0 Bible 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.