ColorPicker uses an Array of Objects with three fields: color, label, and descript. : ColorPicker « Components « Flex






ColorPicker uses an Array of Objects with three fields: color, label, and descript.

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

1.ColorPicker change eventColorPicker change event
2.Get current selected color from ColorPickerGet current selected color from ColorPicker
3.Set color for ColorPickerSet color for ColorPicker
4.Add an event listener for a change event and an open event to ColorPickerAdd an event listener for a change event and an open event to ColorPicker
5.Bind HBox backgroundColor to ColorPicker colorValueBind HBox backgroundColor to ColorPicker colorValue
6.GridItem Label, ColorPickerGridItem Label, ColorPicker
7.Use ControlBar to wrap ColorPicker and Button
8.Change panel style in ColorPicker change eventChange panel style in ColorPicker change event
9.Use a ColorPicker to Set Canvas ColorUse a ColorPicker to Set Canvas Color
10.Populate a ColorPicker with a simple array of colors.Populate a ColorPicker with a simple array of colors.
11.ColorPicker EventsColorPicker Events
12.A ColorPicker uses an Array of Objects with three fields: color, label, and descriptA ColorPicker uses an Array of Objects with three fields: color, label, and descript
13.ColorPicker with Custom Field NamesColorPicker with Custom Field Names