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 entities” on 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 field’s 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 field’s
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>";
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...