Set Flex MX Button background color using CSS

Steve Kuo picture Steve Kuo · Apr 8, 2011 · Viewed 7.6k times · Source

Using CSS, how do I set the background color of a Flex MX Button? My button is declared as:

<mx:Button label="My Button"/>

And the CSS is:

@namespace mx "library://ns.adobe.com/flex/mx";

mx|Button {
    color: #66ffff;
    backgroundColor: #333333;
}

backgroundColor doesn't seem to be the correct CSS property for MX Button's background color. Looking at the Flex API docs, I tried fillColors but that didn't do anything.

Is it possible to change mx.controls.Button's background color using CSS?

Answer

Fseee picture Fseee · Apr 9, 2011

try

Button {
   fillAlphas: 1, 1, 1, 1;
   fillColors: #66ffff, #66ffff, #66ffff, #66ffff;
}

Even if i'd try to use an external .css file

You can create it with Flex Style Explorer and import it by the following statement:

<mx:Style source="yourstylesheet.css" />