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
}
Tagged with:
 

Leave a Reply

Your email address will not be published.

You may 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>

Spam Protection by WP-SpamFree