2012-03-19 53 views
0

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

RichTextEditor不符合我的需要正弦它有多个控件允许用户格式化文本,并且没有办法禁用它们(?)。

UPDATE

另一个问题是如何编码格式。只有<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>'; 
      } 
     } 

如何编写代码的字体颜色?

SOLUTION

我的错误是我用的是象征性的颜色名称,而Flash解释貌似不理解他们

回答

1

这实际上是要解决一个非常简单的问题。 RichTextEditor的设置为showControlBar,如果设置为false,则隐藏花式控件。

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

简介:

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

... 

myRTE.textArea.editable = false; 

这里的一些资源,用于格式化您的htmlTextAdobe 'RichTextEditor Control'Adobe 'using htmlText properly'

+0

谢谢!我是否需要将RTF或HTML放入此控件中? – Dims 2012-03-19 20:20:46

+0

@Dims我添加了一些链接,可以帮助您排除格式。 – 2012-03-20 13:05:42