Table of Contents

E.5 Using HTML for Input and Output

HTML text entered manually into a text field using the Text tool in the Flash authoring tool will not be rendered as HTML. To display HTML-formatted text on screen, we must assign HTML text to a TextField object's htmlText property or, in Flash 5, to the variable associated with the text field. For example:

// Flash 6 syntax
theField_txt.htmlText = "<P><B>Error!</B> <I>No email address!</I></P>";
   
// Flash 5 syntax
theField_txt = "<P><B>Error!</B> <I>No email address!</I></P>";

In Flash 6, the Flash 5 syntax will not only fail to work, it will replace the TextField object with the assigned string! In Flash 6, use of the htmlText property is mandatory.

In the Flash Player, HTML can also be entered into a movie via an HTML-enabled or regular (non-HTML) user-input text field.

When regular text is entered into an HTML-enabled user-input text field, the field's htmlText property includes markup tags that are added automatically. For example, the input text "Hi there" is converted to the htmlText property value:

'<P ALIGN="LEFT"><FONT FACE="Arial" SIZE="10" COLOR="#000000">Hi there</FONT></P>'

When the HTML characters <, >, &, ", and ' are entered into an HTML-enabled user-input text field, the field's htmlText property represents them with the entities &gt;, &lt;, &amp;, &quot;, and &apos;. For example, the input text "<B>hi there</B>" is converted to the htmlText property value:

'<P ALIGN="LEFT"><FONT FACE="Arial" SIZE="10"
 COLOR="#000000">&lt;B&gt;hi there&lt;/B&gt;</FONT></P>'

In both cases, the original (non-marked-up) value is available via the text property.

When regular or HTML text is entered into a normal (non-HTML) user-input text field, no modification of the entered text occurs. Regular user-input text fields allow raw HTML code to be entered into a movie without distortion. This is useful for showing or receiving HTML tags verbatim when you don't want them ignored, rendered, or interpreted.

An example showing HTML-enabled and regular user-input text field data entry is available at the online Code Depot.


Table of Contents