Thursday, April 22, 2010

create an uneditable Flash ActionScript 3.0 TextInput control

The following example shows how you can create an uneditable Flash ActionScript 3.0 TextInput control by setting the Boolean editable property.

Full code after the jump.

// ActionScript 3.0
/* Requires:
* - CheckBox component in Flash library
* - TextInput component in Flash library
*/
import fl.controls.CheckBox;
import fl.controls.TextInput;

var checkBox:CheckBox = new CheckBox();
checkBox.label = "editable";
checkBox.selected = true;
checkBox.addEventListener(Event.CHANGE, checkBox_change);
checkBox.move(10, 10);
addChild(checkBox);

var textInput:TextInput = new TextInput();
textInput.editable = checkBox.selected;
textInput.width = 300;
textInput.move(10, 40);
addChild(textInput);

function checkBox_change(evt:Event):void {
textInput.editable = checkBox.selected;
}

No comments:

Post a Comment