O'Reilly logo

Learning ActionScript 3.0 by Zevan Rosser, Rich Shupe

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 with HTML and CSS

The TextFormat class is great for simple formats of dynamically generated text. But managing a large Flash project this way might become unwieldy if several formats are required. An alternative to this approach is to use HTML and CSS to style the project globally.

HTML

Flash supports a limited subset of HTML tags, as seen in Table 10-1.

Table 10-1. The HTML tags supported by Flash Player

HTML Tag

Notes

<font>

Supported attributes include: color, face, size

<b>

Bold version of font must exist to work

<i>

Italic version of font must exist to work

<u>

Underlines text

<span>

Supported attributes include: class

<p>

multiline must be enabled to work. Supported attributes include: align, class

<br>

multiline must be enabled to work

<li>

All lists are bulleted; ordered and unordered qualifiers are ignored

<img>

Supported attributes include: src, width, height, align, hspace, vspace, id; can embed external images (JPG, GIF, PNG) and SWF files with automatic text flow around the images

<a>

Supported attributes include: href, event, target

<textformat>

Used to apply a limited subset of TextFormat properties to text; supported attributes include: blockindent, indent, leading, leftmargin, rightmargin, tabstops

To use HTML in a text field, you need only switch from using the text property to using the htmlText property. For example, the following code will put the word "Flash" in bold in a text field:

txtFld.htmlText = "<b>Flash</b>";

You should look at the accompanying tables for anything that ...

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