3 Replies Latest reply on Sep 27, 2010 10:57 AM by Devtron

    How to get Combobox Item color

    Devtron Level 3

      Hello, I have setup a combobox, as such:

       

                      <mx:ComboBox id="cb"
                                   change="comboBoxChange"
                                   alternatingItemColors="[
                                                                204
                                                               ,16711680 
                                                               ,16776960
                                                               ,65280
                                                               ,255
                                                               ,65535
                                                               ,16711935
                                                               ,52326
                                                               ,16750848
                                                               ,16711884
                                                               ,10053120
                                                               ,10066176
                                                               ,6684825
                                                               ,16777062
                                                               ,26112
                                                               ,16764057
                                                               ,13408716
                                                               ,13395456
                                                               ,6684672
                                                               ,13421670
                                                               ,10079283
                                                               ,13382655
                                                               ,3368601
                                                               ,13369344
                                                               ,10027059
                                                               ,10053273
                                   ]"
                                   color="black"
                                   >
                          <mx:dataProvider>
                              <fx:Array>
                                  <fx:Object label="Profile 1" />
                                  <fx:Object label="Profile 2" />
                                  <fx:Object label="Profile 3" />
                                  <fx:Object label="Profile 4" />
                                  <fx:Object label="Profile 5" />
                                  <fx:Object label="Profile 6" />
                                  <fx:Object label="Profile 7" />
                                  <fx:Object label="Profile 8" />
                                  <fx:Object label="Profile 9" />
                                  <fx:Object label="Profile 10" />
                                  <fx:Object label="Profile 11" />
                                  <fx:Object label="Profile 12" />
                                  <fx:Object label="Profile 13" />
                                  <fx:Object label="Profile 14" />
                                  <fx:Object label="Profile 15" />
                                  <fx:Object label="Profile 16" />
                                  <fx:Object label="Profile 17" />
                                  <fx:Object label="Profile 18" />
                                  <fx:Object label="Profile 19" />
                                  <fx:Object label="Profile 20" />
                                  <fx:Object label="Profile 21" />
                                  <fx:Object label="Profile 22" />
                                  <fx:Object label="Profile 23" />
                                  <fx:Object label="Profile 24" />
                                  <fx:Object label="Profile 25" />
                                  <fx:Object label="Profile 26" />
                              </fx:Array>
                          </mx:dataProvider>
                      </mx:ComboBox>

       

       

       

       

      Question #1: How can I display the selected Item's color?

       

      I am trying something like this:

                  private function comboBoxChange():void {
                      cb.getStyle("??????"
                  }

       

      But I am unsure what styles are available for "getStyle".

       

      Question #2: Is there any documentation on getStyle and the properties available for a ComboBox?

        • 1. Re: How to get Combobox Item color
          Devtron Level 3

          I think I figured out Question #2, with this documentation URL:

           

          http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/ComboBox.ht ml?allClasses=1

           

           

              Styles
              alternatingItemColors="undefined"
              arrowButtonWidth="22"
              borderColor="0xB7BABC"
              borderThickness="1"
              closeDuration="250"
              closeEasingFunction="undefined"
              color="0x0B333C"
              cornerRadius="0"
              disabledColor="0xAAB3B3"
              disabledIconColor="0x919999"
              dropdownBorderColor="undefined"
              dropdownStyleName="comboDropdown"
              fillAlphas="[0.6,0.4]"
              fillColors="[0xFFFFFF, 0xCCCCCC]"
              focusAlpha="0.4"
              focusRoundedCorners="tl tr bl br"
              fontAntiAliasType="advanced|normal"
              fontFamily="Verdana"
              fontGridFitType="pixel|none|subpixel"
              fontSharpness="0"
              fontSize="10"
              fontStyle="normal|italic"
              fontThickness="0"
              fontWeight="normal|bold"
              highlightAlphas="[0.3,0.0]"
              iconColor="0x111111"
              leading="0"
              openDuration="250"
              openEasingFunction="undefined"
              paddingTop="0"
              paddingBottom="0"
              paddingLeft="5"
              paddingRight="5"
              rollOverColor="Depends on theme color"
              selectionColor="Depends on theme color"
              selectionDuration="250"
              selectionEasingFunction="undefined"
              textAlign="left|center|right"
              textDecoration="none|underline"
              textIndent="0"
              textRollOverColor="0x2B333C"
              textSelectedColor="0x2B333C"
          

           

          I am still unsure about my Question #1: How can I display the selected Item's color?

          • 2. Re: How to get Combobox Item color
            Devtron Level 3

            I am trying this:

                        private function comboBoxChange():void {
                            trace(cb.getStyle("selectionColor"));
                        }

             

             

            but no luck! it always returns "11060974".

             

            I am looking for values from my AlternatingColors array.

             

            Any ideas how to get the color values for those, using 'getStyle' function?

            • 3. Re: How to get Combobox Item color
              Devtron Level 3

              Here is the solution:

               

                          private function comboBoxChange():void {
                 
                              var colors:Array = new Array;
                              var mySelectedColor:String;
                             
                              colors = cb.getStyle("alternatingItemColors");
                              mySelectedColor = colors[cb.selectedIndex];
                     
                          }