ColorPicker uses an Array of Objects with three fields: color, label, and descript.
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
import mx.events.ColorPickerEvent;
import mx.events.DropdownEvent;
[Bindable]
public var complexDPArray:Array = [
{label:"Yellow", color:"0xFFFF00",descript:"Yellow color."},
{label:"Pink", color:"0xFF66CC",descript:"Pink Color"},
{label:"Red", color:"0x990000",descript:"Red Color"},
{label:"Blue", color:"0x000066",descript:"Blue Color"},
{label:"Green", color:"0x006600",descript:"Green Color"},
{label:"Grey", color:"0x666666",descript:"Grey Color"}]
public function openEvt(event:DropdownEvent):void {
descriptBox.text="";
}
public function changeEvt(event:ColorPickerEvent):void {
descriptBox.text=event.currentTarget.selectedItem.label + ": " + event.currentTarget.selectedItem.descript;
}
</mx:Script>
<mx:ArrayCollection id="complexDP" source="{complexDPArray}" />
<mx:VBox>
<mx:TextArea id="descriptBox" width="150" height="50" />
<mx:ColorPicker id="cp"
height="50"
width="150"
dataProvider="{complexDP}"
change="changeEvt(event);"
open="openEvt(event);"
editable="false"/>
</mx:VBox>
</mx:Application>
Related examples in the same category