Skip to Content
ActionScript: The Definitive Guide
book

ActionScript: The Definitive Guide

by Colin Moock
May 2001
Intermediate to advanced
720 pages
23h 24m
English
O'Reilly Media, Inc.
Content preview from ActionScript: The Definitive Guide

User-Input Text Fields

User-input text fields differ from dynamic text fields only in that they may be edited by the user while the movie is playing. That is, a user can type into a user-input text field to change its value. ActionScript can then retrieve and manipulate the user-entered value. User-input text fields are useful for guest books, order forms, password-entry fields, or anywhere you request information from the user.

Creating a User-Input Text Field

To create a user-input text field, follow the same steps described earlier under Section 18.1.1, but choose Input Text instead of Dynamic Text from the Text Type menu.

Changing the Content of an Input Text Field

Like dynamic text fields, user-input text fields may be changed at any time simply by setting the value of the named text field with an assignment statement:

myInputText = "Type your name here";

Because user-input text fields are normally used to accept data rather than display data, we don’t usually set their contents except to provide a default value for the user’s input.

Retrieving and Using the Value of an Input Text Field

You can retrieve the value of a text field by simply referring to it by name in a script. For example, to display the value of an input text field called myInput, use:

trace(myInput);

Because data entered by the user into a user-input text field is always a string datatype, we should convert it explicitly before using it in a non-string context, as demonstrated in this simple calculator example that totals ...

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

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Actionscript Cookbook

Actionscript Cookbook

Joey Lott

Publisher Resources

ISBN: 1565928520Catalog PageErrata