3 Replies Latest reply on Jul 8, 2010 2:09 AM by BhaskerChari

    Inserting colors into a list

    averghese

      Hi,

       

      How do I display colors in a list, I tried using ArrayCollection and all but it didnt work. I got a list with [object Object] displayed in it.

      Can any one give me the code for the same?

        • 1. Re: Inserting colors into a list
          BhaskerChari Level 4

          Hi averghese,

           

          What do you want to display exactly in the List..?? Do you want to display the color codes in the list or the color names or the color BG..??

           

          Can you please tell exactly your problem or post sample code you are working ...

           

          Thanks,

          Bhasker Chari

          • 2. Re: Inserting colors into a list
            averghese Level 1

            Hi,

             

            I want colors to be displayed in the list not the color code. Like a color picker but here it shold be in a list.

             

            averghese

            • 3. Re: Inserting colors into a list
              BhaskerChari Level 4

              Hi averghese,

               

              Check out the below code..It may help you..

               

              <?xml version="1.0"?>

              <!-- controls\colorpicker\CPCustomFieldNames.mxml -->

              <mx:Application

               

               

              xmlns:mx="http://www.adobe.com/2006/mxml">

               

               

               

              <mx:Script>

              <![CDATA[

               

               

              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;

              }

              ]]>

               

              </mx:Script>

               

               

               

              <mx:Style>

               

               

              .myStyle {

               

              swatchWidth:25;

               

              swatchHeight:25;

               

              textFieldWidth:95;

              }

               

              </mx: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>

               

              <mx:Object cName="Yellow" cVal="0xFFFF00"

              cDescript="

              A bright, light color."/>

               

              <mx:Object cName="Hot Pink" cVal="0xFF66CC"

              cDescript="

              It's HOT!"/>

               

              <mx:Object cName="Brick Red" cVal="0x990000"

              cDescript="

              Goes well with warm colors."/>

               

              <mx:Object cName="Navy Blue" cVal="0x000066"

              cDescript="

              The conservative favorite."/>

               

              <mx:Object cName="Forest Green" cVal="0x006600"

              cDescript="

              Great outdoorsy look."/>

               

              <mx:Object cName="Grey" cVal="0x666666"

              cDescript="

              An old reliable."/>

               

              </mx:source>

               

              </mx:ArrayCollection>

               

              </mx:dataProvider>

               

              </mx:ColorPicker>

               

              </mx:VBox>

              </mx:Application>

               

               

               

              Thanks,

              Bhasker Chari