O'Reilly logo

Essential ActionScript 3.0 by Colin Moock

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

Formatting Text Fields

ActionScript provides three different tools for applying text formatting: the flash.text.TextFormat class, HTML, and the flash.text.StyleSheet class. All three tools offer control over the following paragraph and character formatting options, but use different syntax:

Paragraph-level formatting

Alignment, indentation, bullets, leading (line spacing, pronounced "led-ing"), tab stops

Character-level formatting

Font face, font size, font weight (bold or normal), font color, font style (italic or normal), kerning, letter spacing (tracking), text underline, hypertext links

Paragraph-level formatting applies to entire paragraphs, where a paragraph is defined as a span of text delimited by line breaks (\n, <BR>, or <P>). By contrast, character-level formatting applies to arbitrary spans of individual characters, delimited using text indices or HTML or XML tags.

The TextFormat class offers detailed programmatic control over text formatting and is typically used when generating textual output dynamically. The StyleSheet class helps separate formatting instructions from formatted content and is typically used when formatting large bodies of HTML or XML content. HTML formatting instructions offer a simple, intuitive way to format text, but pollute text content with formatting markup. HTML is typically used when convenience is more important than flexibility, as might be the case when formatting text in an application prototype or when formatting short runs of text that are ...

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