2 Replies Latest reply on Jun 28, 2008 4:03 PM by jwoozy

    How to change text color of a button with a skin

    waikitho
      How can I change the text color of a toggle button with a skin? I've created a skin, MyButtonSkin which extends ButtonSkin. Where I override updateDisplayList function, I added things like :

      if (parentButton.selected){
      if (parentButton.getStyle("color") != selectedColor){
      parentButton.setStyle("color", selectedColor);
      }
      }else{
      if (parentButton.getStyle("color") != defaultColor){
      parentButton.setStyle("color", defaultColor);
      }
      }

      What this does is that when the button is pressed, it is toggled to the on position, it will change the color of the text from the default of white to black. But, when I press the button to untoggle it, it does not revert the color back to white.

      Is there a better approach to changing the text color of a button depending on it's state?
      Thanks!