2 Replies Latest reply on May 11, 2010 9:52 AM by TeotiGraphix

    ComboBox > textRollOverColor equivalent for Flex 4, anybody?

    jgraston Level 1

      Does anybody know of an equivalent to textRollOverColor for a ComboBox in Flex 4?  The Spark version of a ComboBox doesn't respond to the text-roll-over-color style property.

       

      Thanks in advance.

       

      Jeremy

        • 1. Re: ComboBox > textRollOverColor equivalent for Flex 4, anybody?
          TeotiGraphix Level 3

          Hi,

           

          Looking at the code there does not seem to be an "easy" way to accomplish this.

           

          The ComboBoxSkin's dropDown uses the DefaultItemRenderer as it's dataGroup. This is where the text is that you need rollOver on. Other than creating a whole new skin for the combo that includes a new item renderer, I don't see this as possible without reskinning.

           

          Mike

          • 2. Re: ComboBox > textRollOverColor equivalent for Flex 4, anybody?
            TeotiGraphix Level 3

            Hi,

             

            I spaced this in my last response;

             

            The itemRenderer property on the ComboBox is what you want. Using the example below yields a new rollOver color.

             

            MyItemRenderer.mxml

             

            <?xml version="1.0" encoding="utf-8"?>
            <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                            xmlns:s="library://ns.adobe.com/flex/spark"
                            xmlns:mx="library://ns.adobe.com/flex/mx"
                            autoDrawBackground="true">

             

                <s:states>

                    <s:State name="normal"/>

                    <s:State name="hovered"/>

                    <s:State name="selected"/>

                    <s:State name="normalAndShowsCaret"/>

                    <s:State name="hoveredAndShowsCaret"/>
                    <s:State name="selectedAndShowsCaret"/>

                </s:states>
               
                <s:Label text="{data}"
                         color.hovered="#FF0000"
                         top="5" right="5" bottom="5" left="5"/>
               
            </s:ItemRenderer>

             

            Application.mxml

             

            ...

             

                <s:ComboBox itemRenderer="MyItemRenderer">
                    <s:dataProvider>
                        <s:ArrayList>
                            <fx:String>One</fx:String>
                            <fx:String>Two</fx:String>
                            <fx:String>Three</fx:String>
                        </s:ArrayList>
                    </s:dataProvider>
                </s:ComboBox>

             

            Using that itemRenderer you could use styles to set the color, then use a selector or something in your application's Style tag to dynamically set the rollOver color.

             

            Mike