ColorPicker with Custom Field Names : ColorPicker « Components « Flex






ColorPicker with Custom Field Names

ColorPicker with Custom Field Names
       

<!--
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\CPCustomFieldNames.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; 
        public function openEvt(event:DropdownEvent):void { 
            descriptBox.text=""; 
        } 
        public function changeEvt(event:ColorPickerEvent):void { 
            descriptBox.text=event.currentTarget.selectedItem.cName + ": " + event.currentTarget.selectedItem.cDescript; 
        } 
      
    </fx:Script>
    <fx:Style>
        .myStyle { swatchWidth:25; swatchHeight:25; textFieldWidth:95; }
    </fx:Style>
    <mx:VBox>
        <mx:TextArea id="descriptBox" width="150" height="50" />
        <mx:ColorPicker id="cp" height="50" width="150" labelField="cName"
            colorField="cVal" change="changeEvt(event)" open="openEvt(event)"
            swatchPanelStyleName="myStyle" editable="false">
            <mx:dataProvider>
                <mx:ArrayCollection>
                    <mx:source>
                        <fx:Object cName="Yellow" cVal="0xFFFF00"
                            cDescript="A bright, light color." />
                        <fx:Object cName="Hot Pink" cVal="0xFF66CC"
                            cDescript="It's HOT!" />
                        <fx:Object cName="Brick Red" cVal="0x990000"
                            cDescript="Goes well with warm colors." />
                        <fx:Object cName="Navy Blue" cVal="0x000066"
                            cDescript="The conservative favorite." />
                        <fx:Object cName="Forest Green" cVal="0x006600"
                            cDescript="Great outdoorsy look." />
                        <fx:Object cName="Grey" cVal="0x666666"
                            cDescript="An old reliable." />
                    </mx:source>
                </mx:ArrayCollection>
            </mx:dataProvider>
        </mx:ColorPicker>
    </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.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