简体   繁体   English

更改按钮状态上的标签颜色(FLex 4)

[英]Change Label Color on Button States (FLex 4)

I have a button in my application and I want it to respond a bit in a special way. 我的应用程序中有一个按钮,我希望它以一种特殊的方式做出响应。 Initially the label color of the button is White, I want the color of the text to change to 50% white on the Over State and to 25% on the Down state. 最初,按钮的标签颜色为白色,我希望文本的颜色在Over状态下变为50%白色,在Down状态下变为25%。 Is this possible? 这可能吗?

I tried an alternative way using css which does not do the percentage stuff but only changes the color (see css code below), but this does not seem to work. 我尝试使用css的另一种方法,该方法不执行百分比填充,而仅更改颜色(请参见下面的css代码),但这似乎不起作用。 I more specifically want the color to change in terms of percentage like I mentioned above. 我更具体地希望颜色按照百分比变化,就像我上面提到的那样。 Can someone help on this one pls? 有人可以帮忙吗?

Note that I am using the Skin file only to loads images for each state on the button. 请注意,我仅使用外观文件来加载按钮上每种状态的图像。

s|Button#specialButton {
 downSkin: Embed(source="text.swf", symbol="btn_focus");
 overSkin: Embed(source="text.swf", symbol="btn_hover");
 upSkin: Embed(source="text.swf", symbol="btn_normal");
 disabledSkin: Embed(source="menuButtons.swf", symbol="btn_disabled");
 skinClass: ClassReference("specialbuttonSkin");
 color:#ffffff;
 textRollOverColor: #ffffff;
 textSelectedColor: #d0d0d0;
}

Thanks for your help. 谢谢你的帮助。

Here's how I would do it: Set the text alpha based on the current state. 这是我的操作方法:根据当前状态设置文本alpha。 The easiest way to achieve this is to set it up in MXML when declaring the instance of your button, like so: 实现此目的最简单的方法是在声明按钮实例时在MXML中进行设置,如下所示:

<s:Button label="My Button" textAlpha.over="0.5" textAlpha.down="0.25"/>

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM