EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Using HTML-Formatted Text

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
436 Working with Text and Strings
Using HTML-formatted text
Flash Player supports a subset of standard HTML tags such as <p> and <li> that you can use
to style text in any dynamic or input text field. Text fields in Flash Player 7 and later also
support the
<img> tag, which lets you embed image files (JPEG, GIF, PNG), SWF files, and
movie clips in a text field. Flash Player automatically wraps text around images embedded in
text fields in much the same way that a web browser wraps text around embedded images in
an HTML page. For more information, see About embedding images, SWF files, and movie
clips in text fields” on page 445.
Flash Player also supports the
<textformat> tag, which lets you apply paragraph formatting
styles of the TextFormat class to HTML-enabled text fields. For more information, see “Using
the TextFormat class” on page 419.
For more information on HTML-formatted text, see the following topics:
“Required properties and syntax for using HTML-formatted text” on page 436
About supported HTML tags” on page 437
About supported HTML entitieson page 444
About embedding images, SWF files, and movie clips in text fields” on page 445
Required properties and syntax for using HTML-
formatted text
To use HTML in a text field, you must set several properties of the text field, either in the
Property inspector or by using ActionScript:
Enable the text fields HTML formatting by selecting the Render Text as HTML option
in the Property inspector or by setting the text field’s
html property to true.
To use HTML tags such as <p>, <br>, and <img>, you must make the text field a
multiline text field by selecting the Multiline option in the Property inspector or by
setting the text fields
multiline property to true.
In ActionScript, set the value of TextField.htmlText to the HTML-formatted text
string you want to display.
For example, the following code enables HTML formatting for a text field named
headline_txt and then assigns some HTML to the text field:
this.createTextField("headline_txt", 1, 10, 10, 500, 300);
headline_txt.html = true;
headline_txt.wordWrap = true;
headline_txt.multiline = true;
headline_txt.htmlText = "<font face='Times New Roman' size='25'>This is how
you assign HTML text to a text field.</font><br>It's very useful.</br>";

Table of Contents

Related product manuals