User Guide
238 Chapter 9: Working with Text
For example, the following HTML code creates the link “Go home,” which opens
www.macromedia.com in a new browser window:
urlText_txt.htmlText = “<a href=’http://www.macromedia.com’ target=’_blank’>Go
home</a>”;
You can use the special asfunction protocol to cause the link to execute an ActionScript
function in a SWF file instead of opening a URL. For more information on the
asfunction
protocol, see
asfunction in Flash ActionScript Language Reference.
You can also define
a:link, a:hover, and a:active styles for anchor tags by using style sheets.
See “Styling built-in HTML tags” on page 231.
Bold tag (<b>)
The
<b> tag renders text as bold, as shown in the following example:
text3_txt.htmlText = "He was <b>ready</b> to leave!";
A bold typeface must be available for the font used to display the text.
Break tag (<br>)
The
<br> tag creates a line break in the text field. In the following example, the line breaks
between sentences:
text1_txt.htmlText = "The boy put on his coat. <br>His coat was <font
color='#FF0033'>red</font> plaid.";
The closing </br> tag is optional, but it is good practice to include it.
Font tag (<font>)
The
<font> tag specifies a font or list of fonts to display the text.
The font tag supports the following attributes:
• color Only hexadecimal color (#FFFFFF) values are supported. For example, the following
HTML code creates red text:
myText_txt.htmlText = "<font color=’#FF0000’>This is red text</font>";
• face Specifies the name of the font to use. As shown in the following example, you can
specify a list of comma-delimited font names, in which case Flash Player selects the first
available font:
myText_txt.htmlText = "<font face=’Times, Times New Roman’>Displays as
either Times or Times New Roman...</font>";
If the specified font is not installed on the user’s computer system or isn’t embedded in the
SWF file, Flash Player selects a substitute font.
For more information on embedding fonts in Flash applications, see
TextField.embedFonts
in Flash ActionScript Language Reference and “Setting dynamic and input text options” in Using
Flash.