O'Reilly logo

ActionScript 3.0 Bible by Roger Braunstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required