13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 20: Basics of Working with text<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

To display text on the scre<strong>en</strong> in Adobe® Flash® Player or Adobe® AIR, use an instance of the TextField class or use the<br />

Flash Text Engine classes. These classes allow you to create, display, and format text. Alternatively, you can use the<br />

Text Layout Framework (TLF) — a compon<strong>en</strong>t library based on the Flash Text Engine classes, but designed for ease<br />

of use. On mobile devices, you can use the StageText class for text input.<br />

You can establish specific cont<strong>en</strong>t for text fields, or designate the source for the text, and th<strong>en</strong> set the appearance of<br />

that text. You can also respond to user ev<strong>en</strong>ts as the user inputs text or clicks a hypertext link.<br />

Both the TextField class and the Flash Text Engine classes allow you to display and manage text in Flash Player and<br />

AIR.You can use the TextField class to create text objects for display and input. The TextField class provides the basis<br />

for other text-based compon<strong>en</strong>ts, such as TextArea and TextInput. You can use the TextFormat class to set character<br />

and paragraph formatting for TextField objects and you can apply Cascading Style Sheets (CSS) using the<br />

Textfield.styleSheet property and the StyleSheet class. You can assign HTML-formatted text, which can contain<br />

embedded media (movie clips, SWF files, GIF files, PNG files, and JPEG files), directly to a text field.<br />

The Flash Text Engine, available starting with Flash Player 10 and Adobe AIR 1.5, provides low-level support for<br />

sophisticated control of text metrics, formatting, and bi-directional text. It also offers improved text flow and <strong>en</strong>hanced<br />

language support. While you can use the Flash Text Engine to create and manage text elem<strong>en</strong>ts, it is primarily designed<br />

as the foundation for creating text-handling compon<strong>en</strong>ts and requires greater programming expertise.The Text<br />

Layout Framework, which includes a text-handling compon<strong>en</strong>t based on the Flash Text Engine, provides an easier way<br />

to use the advanced features of the new text <strong>en</strong>gine. The Text Layout Framework is an ext<strong>en</strong>sible library built <strong>en</strong>tirely<br />

in ActionScript 3.0. You can use the existing TLF compon<strong>en</strong>t, or use the framework to build your own text compon<strong>en</strong>t.<br />

The StageText class, available starting in AIR 3, provides a native text input field. Because this field is provided by the<br />

device operating system, it provides the experi<strong>en</strong>ce with which users of a device are most familiar. A StageText instance<br />

is not a display object. Instead of adding it to the display list, you assign an instance a stage and a display area on that<br />

stage called a viewport. The StageText instance displays in front of any display objects.<br />

For more information on these topics, see:<br />

“Using the TextField class” on page 373<br />

“Using the Flash Text Engine” on page 397<br />

“Using the Text Layout Framework” on page 426<br />

Native text input with StageText<br />

Important concepts and terms<br />

The following refer<strong>en</strong>ce list contains important terms involved with text handling:<br />

Cascading style sheets A standard syntax for specifying styles and formatting for cont<strong>en</strong>t that’s structured in XML (or<br />

HTML) format.<br />

Device font A font that is installed on the user’s machine.<br />

Dynamic text field A text field whose cont<strong>en</strong>ts can be changed by ActionScript but not by user input.<br />

Embedded font A font that has its character outline data stored in the application SWF file.<br />

Last updated 6/6/2012<br />

371

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!