Skip to content
Dec 22 / Peter deHaan

Creating a masked password TextInput control in Flash using ActionScript 3.0

The following example shows ho wyou can create a password Flash ActionScript 3.0 TextInput component by setting the displayAsPassword 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 = "displayAsPassword";
checkBox.addEventListener(Event.CHANGE, checkBox_change);
checkBox.width = 200;
checkBox.move(10, 10);
addChild(checkBox);
 
var textInput:TextInput = new TextInput();
textInput.text = new Date().toString();
textInput.displayAsPassword = checkBox.selected;
textInput.width = 200;
textInput.move(10, 40);
addChild(textInput);
 
function checkBox_change(evt:Event):void {
    textInput.displayAsPassword = checkBox.selected;
}
Leave a Comment