Introduction
Flash MX introduces a rich ActionScript API for working with text in
movies. Prior versions didn't allow much more than
being able to control the value displayed in manually created text
fields.
The TextField class is
used
to create and manipulate text at runtime (though the text itself can
be created either at runtime or authoring time). Through methods and
properties of a text field you can alter text
visibility, change the position of the text within the movie, enable
user input, and much more. In addition, there are two
"helper"
classes—TextFormat
and
Selection—that play a supporting role.
TextFormat objects are used to apply formatting
options such as font, font size, indentation, and margins to
text fields. The Selection
object allows programmatic control over keyboard focus and is helpful
for selecting and deselecting text fields and
the text within them.
Text fields share similar
properties with
MovieClip and Button
objects to control an object's position, rotation,
and visibility, plus others shown in Table 8-1
(for a complete list of TextField properties,
refer to the online help under Help
ActionScript Dictionary).
Table 8-1. TextField graphical display properties|
_x
|
x coordinate of the text field relative to its parent
|
_y
|
y coordinate of the text field relative to its parent
|
_width
|
Width of the text field in pixels
|
_height
|
Height of the text field in pixels
|
_xscale
|
Horizontal scale of the text field as a percentage
|
_yscale
|
Vertical scale of the text field as a percentage
|
_alpha
|
Transparency of the text field (range of 0 to 100)
|
_visible
|
Visibility of the text field object (true or
false)
|
_rotation
|
Clockwise rotation of the text field in degrees
|
_xmouse
|
The cursor's x coordinate relative to the text
field's coordinate system
|
_ymouse
|
The cursor's y coordinate relative to the text
field's coordinate system
|
|