Getting the currently selected color as a hexadecimal value on a ColorPicker control in Flash using ActionScript 3.0

by Peter deHaan on December 23, 2008

in ColorPicker

The following example shows how you can get the currently selected color as a hexadecimal value on a Flash ActionScript 3.0 ColorPicker component by using the read-only hexValue property.

Full code after the jump.

// ActionScript 3.0
/* Requires:
 * - ColorPicker control in Flash library
 * - Label control in Flash library
 */
import fl.controls.ColorPicker;
import fl.controls.Label;
import fl.events.ColorPickerEvent;
 
var colorPicker:ColorPicker = new ColorPicker();
colorPicker.addEventListener(ColorPickerEvent.CHANGE, colorPicker_change);
colorPicker.move(10, 10);
addChild(colorPicker);
 
var lbl:Label = new Label();
lbl.text = colorPicker.hexValue;
lbl.move(10, 40);
addChild(lbl);
 
function colorPicker_change(evt:ColorPickerEvent):void {
    lbl.text = colorPicker.hexValue; // ff0000
}

{ 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: Toggling the text field on the ColorPicker control in Flash using ActionScript 3.0

Next post: Detecting when the user changes the color in a ColorPicker control in Flash using ActionScript 3.0