416 Working with Text and Strings
This ActionScript code can be separated into five key sections. The first section of code
defines a new TextFormat instance that will be applied to a dynamically created text field.
The next two sections create two new text fields on the Stage. The first text field,
lorem_txt, applies the custom text formatting object created earlier, enables embedded
fonts, and sets the
antiAliasType property to true. The second text field,
debug_txt,displays the current sharpness and thickness values for the lorem_txt text
field. The fourth section of code creates a LoadVars object, which is responsible for
loading the external text file and populating the
lorem_txt text field. The fifth, and final,
section of code defines a mouse listener that is called whenever the mouse pointer moves
on the Stage. The current values for
sharpness and thickness are calculated based on
the current position of the mouse pointer on the Stage. The
sharpness and thickness
properties are set for the
lorem_txt text field, and the current values are displayed in the
debug_txt text field.
8. Select Control > Test Movie to test the document.
Move the mouse pointer along the x axis to change the text field’s sharpness. Move the
mouse pointer from left to right to cause the sharpness to increase and appear more
jagged. Move the mouse pointer along the y axis to cause the text field’s thickness to
change.
For more information on using anti-alias text in a SWF file, see “Setting anti-alias with
ActionScript” on page 409, “Font rendering options in Flash” on page 408, and “Using a grid
fit type” on page 417.
A sample file on your hard disk shows how to apply and manipulate anti-aliased text in an
application. You use the FlashType rendering technology to create small text that’s highly
legible. This sample also demonstrates how text fields can scroll quickly and smoothly when
you use the
cacheAsBitmap property.
You can find the sample source file, flashtype.fla, in the Samples folder on your hard disk.
In Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\FlashType.
On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples and
Tutorials/Samples/ActionScript/FlashType.