About supported HTML entities

HTML entities help you display certain characters in HTML formatted text fields, so that they are not interpreted as HTML. For example, you use less-than (<) and greater-than (>) characters to enclose HTML tags, such as <img> and <span>. To display less-than or greater-than characters in HTML-formatted text fields in Flash, you need to substitute HTML entities for those characters. The following ActionScript creates an HTML formatted text field on the Stage and uses HTML entities to display the string "<b>" without having the text appear in bold:

this.createTextField("my_txt", 10, 100, 100, 100, 19);
my_txt.autoSize = "left";
my_txt.html = true;
my_txt.htmlText = "The &lt;b&gt; tag makes text appear <b>bold</b>.";

At runtime, the previous code example in Flash displays the following text on the Stage:

The <b> tag makes text appear bold.

In addition to the greater-than and less-than symbols, Flash also recognizes other HTML entities that are listed in the following table.

Entity

Description

&lt;

< (less than)

&gt;

> (greater than)

&amp;

& (ampersand)

&quot;

" (double quotes)

&apos;

' (apostrophe, single quote)

Flash also supports explicit character codes, such as &#39; (ampersand - ASCII) and &#x0026; (ampersand - Unicode).

The following ActionScript demonstrates how you can use ASCII or Unicode character codes to embed a tilde (~) character:

this.createTextField("my_txt", 10, 100, 100, 100, 19);
my_txt.autoSize = "left";
my_txt.html = true;
my_txt.htmlText = "&#126;"; // tilde (ASCII)
my_txt.htmlText += "\t"
my_txt.htmlText += "&#x007E;"; // tilde (Unicode)

Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00000934.html