MACROMEDIA FLASH 8-COMPONENTS LANGUAGE Reference page 1215

Components language reference
Table of Contents

Advertisement

Creating an application with the TextInput component
The following procedure explains how to add a TextInput component to an application while
authoring. In this example, the component is a password field with an event listener that
determines if the proper number of characters has been entered.
To create an application with the TextInput component:
1.
Drag a TextInput component from the Components panel to the Stage.
2.
In the Property inspector, do the following:
Enter the instance name my_ti.
Leave the text parameter blank.
Set the editable parameter to
3.
Select Frame 1 in the Timeline, open the Actions panel, and enter the following code:
/**
Requires:
- TextInput instance on Stage (instance name: my_ti)
*/
var my_ti:mx.controls.TextInput;
// Create listener object.
var tiListener:Object = new Object();
tiListener.handleEvent = function (evt_obj:Object){
if (evt_obj.type == "enter"){
if (my_ti.length < 8) {
trace("You must enter at least 8 characters");
} else {
trace("Thanks");
}
}
}
// Add listener.
my_ti.addEventListener("enter", tiListener);
This code sets up an
user types less than eight characters, the example displays the message:
at least 8 characters
displays:
Thanks.
4.
After text is entered in the
var my_text:String = my_ti.text;
.
true
event handler on the TextInput instance called
enter
. If the user enters eight or more characters, the example
instance, you can get its value as follows:
my_ti
my_ti
You must enter
Using the TextInput component
. If the
1211

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash 8

Table of Contents