为啥 Alert.show() 不显示文本

Posted

技术标签:

【中文标题】为啥 Alert.show() 不显示文本【英文标题】:Why Alert.show() don't display text为什么 Alert.show() 不显示文本 【发布时间】:2013-05-28 11:07:20 【问题描述】:
Alert.show('Text Copied!', 'Alert Box', mx.controls.Alert.OK);

“文本已复制!” - 不显示

mx.controles.Alert.OK - 也​​不显示在按钮本身

标题中只显示“警告框”,为什么会这样?

【问题讨论】:

可以分享截图吗?是否有可能您在 CSS 中设置的样式无意中影响了警报框? 无法发布图片,因为我没有 10 名声望 :(( 给我点赞,我会发布图片 :),在 CSS 中,我所有的 VBox、HBox、Box 都被锁定了styleName,不,它不是样式......还有什么? @NoobKraker 已投票,您现在应该可以发布屏幕截图了。 @NoobKraker 请参阅我的回答中的示例。 【参考方案1】:

我猜这个常数很糟糕。警报可能使用火花警报,而您传入​​参数 mx.controls.Alert.OK,这意味着它是 mx,而不是火花。试试

mx.controls.Alert.show('Text Copied!', 'Alert Box', mx.controls.Alert.OK);

或使用火花警报参数

【讨论】:

【参考方案2】:

试试下面的代码(css source),非常简单,完美运行:

    <?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;

            public function init():void
                Alert.show('Text Copied!', 'Alert Box', mx.controls.Alert.OK);
            
        ]]>
    </mx:Script>

    <mx:Style>
        Alert
            color : #124332;
            background-color: #ffffff;
            header-colors : #243322, #243322;
            header-height:19;
            drop-shadow-enabled: true;
            drop-shadow-color :#243322;
            corner-radius :6;
            border-style :solid;
            border-thickness: 1;
            border-color : #243322;
            footer-colors : #243322, #ffffff;
            title-style-name : "title";
        
        .title
            font-family :Verdana;
            font-size :10;
            font-weight :bold;
            color :#ffffff;
        
    </mx:Style>
</mx:Application>

【讨论】:

以上是关于为啥 Alert.show() 不显示文本的主要内容,如果未能解决你的问题,请参考以下文章

为啥当我点击文本字段时工具栏不显示?

为啥反应文本组件不显示对我的数组状态的更新

为啥我的 UITextView 文本从开始时不显示并隐藏在导航栏下

为啥wps表格合并公式只显示公式不显示结果?

德尔福。为啥要在 Windows 7 64 位上以发布模式编译程序。但是文本框不显示文本?

当我添加自动布局约束时,为啥我的 textview 不显示?