8.12. Using HTML Tags in Text

Problem

You want to use HTML tags in text fields or text areas.

Solution

For text area components, set the html parameter to true using the Component Inspector panel. Then assign the HTML text to the component’s text parameter.

For text fields, activate the Render Text as HTML option within the Property inspector. Or set its html property to true using ActionScript. In either case, after you’ve set the text field to render HTML, you can then assign the HTML text to the field’s htmlText ActionScript property. (You cannot assign HTML text to a text field at authoring time.)

Discussion

You can instruct Flash to render text field and text area content as HTML rather than plain text, which is an effective and relatively simple way to apply some formatting to your text without having to use extensive ActionScript. For example, you can add hyperlinks, color, and style changes all with basic HTML tags.

There are two main steps in using HTML in your text fields and text areas. The steps in either case amount to basically the same thing—telling Flash to render the text within the instance as HTML rather than plain text, and assigning the HTML to the instance. However, the steps are slightly different depending on whether you are using a text field or a text area.

If you are using a text area, complete the following two steps:

  1. With the text area selected, set the html parameter to true using the Component Inspector panel.

  2. Assign the HTML text to the text area by way of ...

Get Flash 8 Cookbook 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.