Recipe 9.3. Making
a User Input Field
Problem
You
want to create a user input field
to allow the user to enter text.
Solution
Set the text field's type property to
TextFieldType.INPUT.
Discussion
There are two types of text fields: dynamic and input. The default text
field type is dynamic. This means that it can be controlled with
ActionScript, but the user cannot input text into it. To enable the
field for user input, set the type property to the
INPUT constant of the flash.display.TextFieldType
class:
field.type = TextFieldType.INPUT;
Though it isn't a requirement, input fields
generally also have a border and a background. Otherwise, the user
might find it difficult to locate and select the field:
field.border = true;
field.background = true;
For a user to be able to input text, the field's
selectable property must be true, which is the
default. You don't need to set the selectable property to
true, unless you previously set it to false.
If you have previously defined an input text
field that you want to make a dynamic text field (so that it does
not accept user input) you can set the type property to the
DYNAMIC constant of the flash.display.TextFieldType
class:
field.type = TextFieldType.DYNAMIC;
|