Home | Contact Us | Store

Move text between Text Field with Flash ActionScript 3

Buttons and text Fields are the best friends of Flash Movies. You always see them in most Flash Movies. In this Flash ActionScript 3 tutorial series, we will work with Button and Text Fields.
Your flash player version is too old to see this video file!

Flash Tutorial Content:

Most Flash Movies use buttons to control objects on the stage. In this Flash tutorial, we learn how to write a simple function with ActionScript 3. And then we learn how to hook up a button with the function.

Input some texts in the above Flash Movie and click the Enter button to see how it works.

Flash ActionScript Codes:

// We need Keybpard control
import flash.events.KeyboardEvent;

// Allow Text Fields to input data
inputText1_txt.type = TextFieldType.INPUT;

// Set the mouse cursor to focus on the first field
inputText1_txt.stage.focus = inputText1_txt;

// write a function to display the text in the TextField
// to the Message Box
function readText(evt:Event):void {

// Check if data are entered in the text field
if (inputText1_txt.text == ""){
output_txt.text = "Field is Empty!";
} else {
output_txt.text = inputText1_txt.text;
}
}

// Hook up the button with the function readText
enter_btn.addEventListener(MouseEvent.CLICK, readText);

Download Flash Source File:

Flash Source File text-1.fla

Remarks:

Usually the Dynamic Text Field is used to handle string (text) in Flash Movies. In next tutorial, we will use Dynamic Text Fields to handle numbers so that so can do some arithmatic caculation.

Button and Textfield ActionScript Tutorial