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