Creating Text Fields with ActionScript
You've seen how to create and then display objects using ActionScript (The Display List: Everything in Its Place), and text fields are no different. You create, and if needed, format the object, and then you use the addChild() method to add the text field to the Display List. Objects added to the Display List are on the stage, and they're visible unless you've programmed them otherwise.
ActionScript has two text field classes. The TextField class is the basis for Classic text: static, dynamic, and input. Use the TLFTextField class to create TLF text. Fortunately, the properties and methods in both classes are nearly identical, so if you know how to use one, then you can use the other, too. For example, both text fields use the .text property to define the characters displayed in the text field—more on that later. The following examples use the new TLFTextField, which offers more bells and whistles, but it shouldn't be hard to translate the techniques to a Classic TextField.
Note
The properties and methods related to TLF text fields are defined by the TLFTextField class. That means if you ever have a question, or if you're ever digging deeper for details about text, you can look up "TLFTextField" in the ActionScript 3.0 and Components reference (Getting Help for Events and Event Listeners), where you'll find a listing of all the properties, methods, and events that are part of the TLFTextField class. This section will familiarize you with quite ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access