EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 419

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...
About text layout and formatting 419
The preceding ActionScript code can be separated into five sections. The first section
defines a new text format object that specifies two properties,
size and font. The font
property refers to the linkage identifier of the font symbol currently in the document
library. The second, third, and fourth sections of code each create a new dynamic text field
on the Stage and set some common properties:
antiAliasType (which must be set to
advanced), embedFonts (set to true), multiline, and wordWrap. Each section also
applies the text format object created in an earlier section, and sets the grid fit type to
normal, pixel, or subpixel. The fifth, and final, section creates a LoadVars instance,
which loads the contents of an external text file into each of the text fields that you created
with code.
9. Save the document and select Control > Test movie to test the SWF file.
Each text field should be initialized with the value “
loading.... After the external text file
is successfully loaded, each text field displays some formatted sample text using a different
grid-fit type.
Using the TextFormat class
You can use the TextFormat class to set the formatting properties of a text field. The
TextFormat class incorporates character and paragraph formatting information. Character
formatting information describes the appearance of individual characters: font name, point
size, color, and an associated URL. Paragraph formatting information describes the
appearance of a paragraph: left margin, right margin, indentation of the first line, and left,
right, or center alignment.
To use the TextFormat class, you first create a TextFormat object and set its character and
paragraph formatting styles. You then apply the TextFormat object to a text field using the
TextField.setTextFormat() or TextField.setNewTextFormat() method.
The setTextFormat() method changes the text format that is applied to individual
characters, to groups of characters, or to the entire body of text in a text field. Newly inserted
text, however—such as text entered by a user or inserted with ActionScript—does not assume
the formatting specified by a
setTextFormat() call. To specify the default formatting for
newly inserted text, use
TextField.setNewTextFormat(). For more information, see
setTextFormat (TextField.setTextFormat method) and setNewTextFormat
(TextField.setNewTextFormat method) in the ActionScript 2.0 Language Reference.
TIP
The FlashType rendering technology uses grid fitting only at 0º rotation.

Table of Contents

Related product manuals