更改 Flex 4 Spark 按钮的颜色

发布于 2024-10-08 00:30:01 字数 140 浏览 0 评论 0原文

有没有一种简单的方法可以更改 Flex 4 Spark 按钮的背景颜色而不弄乱皮肤?

更新:好的,弄清楚了,只需设置按钮 mxml 的 chromeColor 属性即可。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

纵性 2024-10-15 00:30:01

对于 Spark 组件,您可以使用 chromeColor 样式:

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

一身仙ぐ女味 2024-10-15 00:30:01

您可以更改按钮的颜色样式。您还可以进行位图填充。

更新:以上方法不会改变背景。

更改背景的最简单方法是使用 - opaqueBackground 属性。

这是更改按钮背景而不更改其皮肤的另一种方法 -
1. 创建一个包含矩形和按钮的组。
2. 将按钮的 opaqueBackground 设置为 null。
3. 将矩形的widthheight设置为100%
4. 填充矩形的颜色就是按钮的背景。

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.

贪恋 2024-10-15 00:30:01

这也可以通过如下代码来完成:-

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)
}

如果有人想更改鼠标悬停时的背景颜色,我正在发布它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文