Set Properties to TextField with Flash ActionScript 3
Flash Tutorial Content:
This flash tutorial will set some properties (e.g. position, border, auto-size, etc...) to the Text Field that created by Flash ActionScript in previous tutorial.
Flash ActionScript Codes:
///////////////////////////////////////////
///// Create New TextField /////
//////////////////////////////////////////
// Create a textfield object with the name "textField_txt"
var textField_txt:TextField = new TextField();
// Add the new textfield_txt instance to the stage
addChild(textField_txt);
// Add Content to TextField
textField_txt.text = "Hello World";
////////////////////////////////////////////
///// Set BASIC Properties /////
///////////////////////////////////////////
// Set position of TextField (x = Left, y = Top)
textField_txt.x = 150;
textField_txt.y = 200;
// Set width of Text Field
textField_txt.width = 350;
//////////////////////////////////////////
///// Set Other Properties /////
/////////////////////////////////////////
// Text not selectable
textField_txt.selectable = false;
// Text border
textField_txt.border = false;
// Autosize with the text and align to the left.
textField_txt.autoSize = TextFieldAutoSize.LEFT;
Download Flash Source File:
Remarks:
In the next Flash ActionScript tutorial, we will set some Text Format (e.g. Text Size, Text Color, etc..) to the Text Field.