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

by Peter deHaan on December 23, 2008

in ColorPicker

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();
}

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Previous post:

Next post: