This section lists the built-in HTML tags supported by Flash Player. You can also create new styles and tags using CSS; see Formatting text with Cascading Style Sheets.
The <a> tag creates a hypertext link and supports the following attributes:
href Specifies the URL of the page to load in the browser. The URL can be either absolute or relative to the location of the SWF file that is loading the page. An example of an absolute reference to a URL is http://www.macromedia.com; an example of a relative reference is /index.html.
target Specifies the name of the target window where you load the page. Options include _self, _blank, _parent and _top. The _self option specifies the current frame in the current window, _blank specifies a new window, _parent specifies the parent of the current frame, and _top specifies the top-level frame in the current window.
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.
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.
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.
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.
size Specifies the size of the font, in pixels, as shown in the following example:
myText_txt.htmlText = "<font size='24' color='#0000FF'>This is blue, 24- point text</font>";
You can also use relative point sizes instead of a pixel size, such as +2 or -4.
The <img> tag lets you embed external JPEG files, SWF files, and movie clips inside text fields and TextArea component instances. Text automatically flows around images you embed in text fields or components. This tag is supported only in dynamic and input text fields that are multiline and wrap their text.
MovieClip.createTextField(), set the new text field instance's TextField.multiline and TextField.wordWrap properties to true.
The <img> tag has one required attribute, src, which specifies the path to a JPEG file, a SWF file, or the linkage identifier of a movie clip symbol in the library. All other attributes are optional.
The <img> tags supports the following attributes:
src Specifies the URL to a JPEG or SWF file, or the linkage identifier for a movie clip symbol in the library. This attribute is required; all other attributes are optional. External files (JPEG and SWF files) do not show until they have downloaded completely.
Note: Flash Player supports non-progressive JPEG files, but does not support progressive JPEG files.
id Specifies the name for the movie clip instance (created by Flash Player) that contains the embedded JPEG file, SWF file, or movie clip. This is useful if you want to control the embedded content with ActionScript.
width The width of the image, SWF file, or movie clip being inserted, in pixels.
height The height of the image, SWF file, or movie clip being inserted, in pixels.
align Specifies the horizontal alignment of the embedded image within the text field. Valid value are left and right. The default value is left.
hspace Specifies the amount of horizontal space that surrounds the image where no text appears. The default value is 8.
vspace Specifies the amount of vertical space that surrounds the image where no text appears. The default value is 8.
For more information and examples of using the <img> tag, see Embedding images, SWF files, and movie clips in text fields.
The <i> tag displays the tagged text in italics, as shown in the following code:
That is very <i>interesting</i>.
This code example would render as follows:
That is very interesting.
An italic typeface must be available for the font used.
The <li> tag places a bullet in front of the text that it encloses, as shown in the following code:
Grocery list: <li>Apples</li> <li>Oranges</li> <li>Lemons</li>
This code example would render as follows:
Grocery list:
Note: Ordered and unordered lists (<ol> and <ul> tags) are not recognized by Flash Player, so they do not modify how your list is rendered. All list items use bullets.
The <p> tag creates a new paragraph. It supports the following attributes:
align Specifies alignment of text within the paragraph; valid values are left, right, and center.
class Specifies a CSS style class defined by an TextField.StyleSheet object. (For more information, see Using style classes.)
The following example uses the align attribute to align text on the right side of a text field.
myText_txt.htmlText = "<p align='right'>This text is aligned on the right side of the text field</p>";
The following example uses the class attribute to assign a text style class to a <p> tag:
var myStyleSheet = new TextField.StyleSheet();
myStyleSheet.setStyle("body", {color:'#99CCFF', fontSize:'18'});
this.createTextField("test", 10, 0, 0, 300, 100);
test.styleSheet = myStyleSheet;
test.htmlText = "<p class='body'>This is some body-styled text.</p>.";
The <span> tag is available only for use with CSS text styles. (For more information, see Formatting text with Cascading Style Sheets.) It supports the following attribute:
class Specifies a CSS style class defined by an TextField.StyleSheet object. For more information on creating text style classes, see Using style classes.
The <textformat> tag lets you use a subset of paragraph formatting properties of the TextFormat class within HTML text fields, including line leading, indentation, margins, and tab stops. You can combine <textformat> tags with the built-in HTML tags.
The <textformat> tag has the following attributes:
blockindent Specifies the block indentation in points; corresponds to TextFormat.blockIndent. (See TextFormat.blockIndent in Flash ActionScript Language Reference.)
indent Specifies the indentation from the left margin to the first character in the paragraph; corresponds to TextFormat.indent. (See TextFormat.indent in Flash ActionScript Language Reference.)
leading Specifies the amount of leading (vertical space) between lines; corresponds to TextFormat.leading. (See TextFormat.leading in Flash ActionScript Language Reference.)
leftmargin Specifies the left margin of the paragraph, in points; corresponds to TextFormat.leftMargin. (See TextFormat.leftMargin in Flash ActionScript Language Reference.)
rightmargin Specifies the right margin of the paragraph, in points; corresponds to TextFormat.rightMargin. (See TextFormat.rightMargin in Flash ActionScript Language Reference.)
tabstops Specifies custom tab stops as an array of non-negative integers; corresponds to TextFormat.tabStops. (See TextFormat.tabStops in Flash ActionScript Language Reference.)
The following code example uses the tabstops attribute of the <textformat> tag to create a table of data with boldfaced row headers:
| Name | Age | Department |
|---|---|---|
|
Tim |
32 |
Finance |
|
Edwin |
46 |
Marketing |
table_txt, select Multiline from the Line Type pop-up menu, and select the Render Text as HTML option.
//Creates column headers, formatted in bold, separated by tabs var rowHeaders = "<b>Name\tAge\tDepartment</b>"; //Creates rows with data var row_1 = "Tim\t32\tFinance"; var row_2 = "Edwin\t46\tMarketing"; //Sets two tabstops, to 50 and 100 points table_txt.htmlText = "<textformat tabstops='[50,100]'>"; table_txt.htmlText += rowHeaders; table_txt.htmlText += row_1; table_txt.htmlText += row_2 ; table_txt.htmlText += "</textformat>";
The use of the tab character escape sequence (\t) adds tabs between each column in the table.
The <u> tag underlines the tagged text, as shown in the following code:
This is <u>underlined</u> text.
This code would render as follows:
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00001040.html
Comments
recoveredfromflashMX2004 said on Jul 27, 2004 at 11:07 AM : recoveredfromflashMX2004 said on Jul 27, 2004 at 11:08 AM : shimi2 said on Aug 13, 2004 at 1:05 PM :