O'Reilly logo

Actionscript Cookbook by Joey Lott

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Text

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

Property

Description

_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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required