6

Is there an easy way to change the background color of a Flex 4 spark Button without messing with skins?

UPDATE: ok, figured it out, simply set the chromeColor attribute of the Button mxml.

zero323
  • 322,348
  • 103
  • 959
  • 935
at.
  • 50,922
  • 104
  • 292
  • 461

3 Answers3

6

For spark components, you can use chromeColor style:
<s:Button chromeColor="0xff0000" label="chrome red"/>

Chaitanya K
  • 1,827
  • 4
  • 32
  • 67
ptrk
  • 1,800
  • 1
  • 15
  • 24
1

This can also be done via code like :-

btnID.addEventListener(MouseEvent.MOUSE_OVER, textChange);
btnID.addEventListener(MouseEvent.MOUSE_OUT, textChangeback);

private function textChange(event:MouseEvent):void
{
    btnLinkDelete.setStyle("color", 0xFFFFFF)
    btnLinkDelete.setStyle("chromeColor", 0x535151)
}

private function textChangeback(event:MouseEvent):void
{
    btnLinkDelete.setStyle("color", 0x000000)
    btnLinkDelete.setStyle("chromeColor", 0xfcffff)
}

I am posting it, if anyone want to change background color on mouse hover.

AnandMeena
  • 528
  • 3
  • 11
  • 26
1

You can change the color style of the button. You can also have a bitmap fill.

Update: The above methods do not change the background.

Easiest way to change the background, you can use - opaqueBackground property.

Here is another way to change the background of a button without changing its skin - 1. Create a group with a rectangle and your button. 2. Set opaqueBackground of your button to null. 3. Make width and height of rectangle to 100% 4. whatever color you fill the rectangle with is the background of your button.

nuaavee
  • 1,336
  • 2
  • 16
  • 31
  • How do I change the color style? If I do it just changes the Label, not the background. – at. Dec 15 '10 at 23:48