Flex Alert.styleName不适合我 [英] Flex Alert.styleName not working for me

查看:142
本文介绍了Flex Alert.styleName不适合我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码,但是风格没有应用。我看过网络上的文章这应该工作。任何想法?

  var alert:Alert = Alert.show(您尚未储存变更。\\\
\\\
Would你想现在保存吗?,
保存答案?,
Alert.NO | Alert.YES | Alert.CANCEL,
this,
handleUnsavedChanges,
null,
Alert.YES);

alert.styleName =alertStyle;



尝试使用样式表中的Alert类设置样式似乎有效,但会发出警告。我想找到已批准的方式。



BTW,这是Flex 3。



- 我也尝试过像

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

私有函数showAlert(color:Object):void {
alertCSS.setStyle(backgroundColor,0x00FF00);
alert = Alert.show(The quick brown fox ...);
}


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.

解决方案

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

这篇关于Flex Alert.styleName不适合我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆