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






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

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

<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->


<!-- controls\colorpicker\CPObjects.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx">
    <fx:Script>
         
        import mx.events.ColorPickerEvent; 
        import mx.events.DropdownEvent; 
        [Bindable] 
        public var complexDPArray:Array = [ 
        {label:"Yellow", color:"0xFFFF00", descript:"A bright, light color."}, 
        {label:"Hot Pink", color:"0xFF66CC",descript:"It's HOT!"}, 
        {label:"Brick Red", color:"0x990000",descript:"Goes well with warm colors."}, 
        {label:"Navy Blue", color:"0x000066",descript:"The conservative favorite."}, 
        {label:"Forest Green", color:"0x006600",descript:"Great outdoorsy look."}, 
        {label:"Grey", color:"0x666666", descript:"An old reliable."}] 
        public function openEvt(event:DropdownEvent):void { 
            descriptBox.text=""; 
        } 
        public function changeEvt(event:ColorPickerEvent):void { 
           descriptBox.text=event.currentTarget.selectedItem.label + ": " + event.currentTarget.selectedItem.descript; 
        } 
      
    </fx:Script>
    <fx:Style>
        .myStyle { swatchWidth:25; swatchHeight:25; textFieldWidth:95; }
    </fx:Style>
    <!-- Convert the Array to an ArrayCollection. Do this if 
        you might change the colors in the panel dynamically. -->
    <fx:Declarations>
        <mx:ArrayCollection id="complexDP" source="{complexDPArray}" />
    </fx:Declarations>
    <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>
</s: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.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.
6.Bind HBox backgroundColor to ColorPicker colorValueBind HBox backgroundColor to ColorPicker colorValue
7.GridItem Label, ColorPickerGridItem Label, ColorPicker
8.Use ControlBar to wrap ColorPicker and Button
9.Change panel style in ColorPicker change eventChange panel style in ColorPicker change event
10.Use a ColorPicker to Set Canvas ColorUse a ColorPicker to Set Canvas Color
11.Populate a ColorPicker with a simple array of colors.Populate a ColorPicker with a simple array of colors.
12.ColorPicker EventsColorPicker Events
13.ColorPicker with Custom Field NamesColorPicker with Custom Field Names