2012-03-19 66 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