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.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...