Change color of a Flex 4 spark Button
Asked Answered
C

3

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.

Credulity answered 15/12, 2010 at 23:26 Comment(0)
D
6

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

Donor answered 27/12, 2012 at 11:46 Comment(0)
A
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.

Arcadia answered 15/12, 2010 at 23:39 Comment(1)
How do I change the color style? If I do <s:Button label="This text will be blue, but not the background" color="#0000FF"/> it just changes the Label, not the background.Credulity
P
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.

Press answered 14/1, 2014 at 6:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.