我有这段代码,但没有应用样式。我看过articles on the web这应该在哪里工作。有什么想法吗?
var alert:Alert = Alert.show("You have not saved you changes.\n\nWould you like to save now?",
"Save Answers?",
Alert.NO | Alert.YES | Alert.CANCEL,
this,
handleUnsavedChanges,
null,
Alert.YES);
alert.styleName = "alertStyle";
尝试使用样式表中的 Alert 类设置样式似乎可行,但会引发警告。我想找到“批准”的方式。
顺便说一句,这是 Flex 3。
PS - 我也尝试过类似的东西
alert.setStyle("backgroundColor", "0x00FF00");
但这似乎也不起作用。我觉得我需要调用一些东西来告诉 Alert 框重绘自己,但我不知道如何。
最佳答案
您可以创建自定义类以使用特定的 css:
public class CustomAlert extends Alert {}
... 然后在 CSS 中
CustomAlert
{
background-color: #00FF00;
}
或者更复杂一点的例子:
import mx.styles.StyleManager;
private function init():void {
alertCSS = StyleManager.getStyleDeclaration("Alert");
}
private function showAlert(color:Object):void {
alertCSS.setStyle("backgroundColor", "0x00FF00");
alert = Alert.show("The quick brown fox...");
}
关于css - Flex Alert.styleName 对我不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7405943/