Flex Alert.styleName 不适合我

发布于 2024-12-04 15:33:34 字数 857 浏览 1 评论 0原文

我有这段代码,但样式没有被应用。我见过网络上的文章,这应该起作用。有什么想法吗?

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");

,但这似乎也不起作用。我觉得我需要调用一些东西来告诉警报框重新绘制自身,但我不知道如何。

I have this code, but the style is not being applied. I've seen articles on the web where this should work. Any ideas?

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";

Attempting to set the style using the Alert class in my stylesheet seems to work, but throws a warning. I'd like to find the "approved" way.

BTW, this is Flex 3.

PS - I've also tried stuff like

alert.setStyle("backgroundColor", "0x00FF00");

but this does not seem to work either. I feel like I need to call something to tell the Alert box to redraw itself, but I don't know how.

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

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

发布评论

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

评论(1

杀手六號 2024-12-11 15:33:34

您可以创建一个自定义类以使用特定的 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...");
        }

You could create a custom class in order to use specific css:

public class CustomAlert extends Alert {}

... Then in the CSS

CustomAlert 
{
    background-color: #00FF00;
}

Or a little more complicated example:

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