
TextField._url Property
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
878
|
ActionScript Language Reference
When type is set to “input”, the user can enter text into the field and we can examine the
input via its
text property (see TextField.text for a code sample). When type is set to
“dynamic”, the user cannot type into the field. However, characters can still be selected
unless
selectable is set to false explicitly. Unicode text can be entered into input text
fields when Unicode is supported by the operating system.
Because data entered by the user into an input text field is always a string, we should
convert it explicitly before using it in a nonstring context, as demonstrated in this simple
calculator example that totals two user-input text fields:
// Suppose myFirstInput is 5, mySecondInput is 10, and we total the fields.
// WRONG: "Adding" the fields together sets myOutput to "Total: 510"
// because the + operator is interpreted as a string concatenator.
myOutput.text = "Total: " + (myFirstInput.text + mySecondInput.text);
// RIGHT: First, convert the fields to numbers in order to get the right result.
myOutput.text = "Total: " + (parseFloat(myFirstInput.text)
+ parseFloat(mySecondInput.text));
Example
The following example creates a title that can neither be selected nor receive input:
this.createTextField("title_txt", 1, 0, ...