2 Replies Latest reply on Mar 19, 2010 9:03 AM by sub_tex

    CSS for button states not working after a setStyle

    sub_tex

      In my CSS file, I have this:

       

      Controls|Button{
          BorderThickness: 10;
      }


      Controls|Button:over{
          BorderThickness: 5;
      }

       

      And that works fine.

       

      But I also have a NumericStepper on the stage that lets me dynamically change the BorderThickness as well.  The changehandler for that stepper is just doing a setStyle("BorderThickness", stepper.value) on the button.

       

      And that works.

       

      But what it also does is set that thickness for ALL states of the button.  The "over" style set in the CSS is no longer used.

       

      Given that this is a custom style, is there some logic I need to be handling in the skin to have the CSS state settings still be taken into consideration?

        • 1. Re: CSS for button states not working after a setStyle
          CoreyRLucier Adobe Employee

          I think you are just running into an order of precedence issue, per the docs for setStyle (see IStyleClient), "This may override a style that was set globally."

           

          Locally set styles take precedence over cascading/global styles.  You'd need to remove the explicit style from the states it shouldn't apply (clearStyle).

           

          -C

          • 2. Re: CSS for button states not working after a setStyle
            sub_tex Level 1

            I understand that, but in this case I am not setting a new BorderThickness value for it's "over" state.

             

            If I have CSS defined for up, over, down, and disabled, I don't see how setting a general setStyle with no state deliniation would override the ones that were already there.

             

            Or at the very least there should be a way via AS to do setStyle("BorderThickness:over", 12) or something.

             

            If I can set state specific value in mxml, I should be able to do that in AS too, no?