【问题标题】:Flash builder read-only rich text field?Flash builder只读富文本字段?
【发布时间】:2012-03-19 19:55:46
【问题描述】:

如何在 flash TextArea 或类似控件中显示具有简单格式(如字体颜色)的文本?我需要以编程方式将文本添加到此控件,并能够选择其中的一部分并将其复制到剪贴板。

RichTextEditor 不符合我的需求,因为它有多个控件允许用户设置文本格式并且无法禁用它们 (?)。

更新

另外一个问题是如何编码格式化。只有<b> 在以下代码中起作用:

private function Print(s:String, ... optionalArgs):void {
            if( optionalArgs.length == 0 || optionalArgs[0]==0) {
                mLog.htmlText = mLog.htmlText + '<b>' + s + '</b><br>';
            }
            else if(optionalArgs[0]==-1) {
                mLog.htmlText = mLog.htmlText + '<font color=\"red\">' + s + '</font><br>';
            }
            else if(optionalArgs[0]==1) {
                mLog.htmlText = mLog.htmlText + '<span style=\"color:green\">' + s + '</span><br>';
            }
            else if(optionalArgs[0]==2) {
                mLog.htmlText = mLog.htmlText + '<span style=\"color:blue\">' + s + '</span><br>';
            }
            else {
                mLog.htmlText = mLog.htmlText + '<b>' + s + '</b><br>';
            }
        }

如何编码字体颜色?

解决方案

我的错误是我使用了符号颜色名称,而 Flash 解释器看起来不理解它们

【问题讨论】:

    标签: actionscript-3 flash-builder richtextbox mxml


    【解决方案1】:

    这其实是一个很容易解决的问题。 RichTextEditor 有一个showControlBar 设置,如果设置为false,隐藏花哨的控件。

    此外,您可以访问内部文本区域并使其不可编辑 (myRTE.textArea.editable= false),从而限制用户与文本的交互。

    简介:

    <mx:RichTextEditor id="myRTE" showControlBar="false"... />
    
    ...
    
    myRTE.textArea.editable = false;
    

    这里有一些用于格式化htmlText 的资源:@​​987654321@、Adobe 'using htmlText properly'

    【讨论】:

    • 谢谢!我需要将 RTF 或 HTML 放入此控件吗?
    • @Dims 我添加了一些链接,可以帮助您进行格式化。
    猜你喜欢
    • 1970-01-01
    • 2019-04-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-25
    • 2014-03-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多