Skip to content
Dec 23 / Peter deHaan

Toggling the text field on the ColorPicker control in Flash using ActionScript 3.0

The following example shows how you can toggle the text field on the Flash ActionScript 3.0 ColorPicker control by setting the Boolean showTextField property.

Full code after the jump.

// ActionScript 3.0
/* Requires:
 * - CheckBox control in Flash library
 * - ColorPicker control in Flash library
 */
import fl.controls.CheckBox;
import fl.controls.ColorPicker;
 
var checkBox:CheckBox = new CheckBox();
checkBox.selected = true;
checkBox.label = "showTextField";
checkBox.addEventListener(Event.CHANGE, checkBox_change);
checkBox.textField.autoSize = TextFieldAutoSize.LEFT;
checkBox.move(10, 10);
addChild(checkBox);
 
var colorPicker:ColorPicker = new ColorPicker();
colorPicker.move(10, 40);
addChild(colorPicker);
 
function checkBox_change(evt:Event):void {
    colorPicker.close();
    colorPicker.showTextField = checkBox.selected;
    colorPicker.open();
}
Leave a Comment