apache-flex - 在 Spark TextArea 中显示 HTML 文本

标签 apache-flex flexbuilder flex3 flex4

下面的代码运行良好...

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark" 
      xmlns:mx="library://ns.adobe.com/flex/mx" >
 <fx:Declarations>
  <mx:HTTPService id="httpRSS" url="http://www.petefreitag.com/rss/" resultFormat="object" />
 </fx:Declarations>
  <s:Panel id="reader" title="Blog Reader" width="500">
  <mx:DataGrid width="485" id="entries" dataProvider="{httpRSS.lastResult.rss.channel.item}" click="{body.htmlText=httpRSS.lastResult.rss.channel.item[entries.selectedIndex].description}">
   <mx:columns>
    <mx:DataGridColumn dataField="title" headerText="TITLE"/>
    <mx:DataGridColumn dataField="pubDate" headerText="Date"/>    
   </mx:columns>
  </mx:DataGrid>
  <mx:TextArea id="body" editable="false" width="485" x="3" y="142" height="155"/>
 </s:Panel>
 <s:Button label="Load" x="10" y="329" click="{httpRSS.send()}"/>
 </s:Application>

但是当 Textarea 更改为像下面这样触发 Textrea 时

<s:TextArea id="body" editable="false" width="485" x="3" y="142" height="155"/>

那么 htmlText 不支持 Spark Textarea。因此产生错误。如何使用 spark 文本区域属性显示 HTML 格式的文本。

最佳答案

如果您使用的是 RichEditableText 组件,则可以使用 TextConverter 类以这种方式进行操作

var myStr:String = "I contain <b>html</b> tags!";           
myRichEditableText.textFlow = TextConverter.importToFlow(myStr, TextConverter.TEXT_FIELD_HTML_FORMAT);

关于apache-flex - 在 Spark TextArea 中显示 HTML 文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3326334/

相关文章:

apache-flex - 为什么用于 eclipse 的 is flexbuilder 插件打开和编译这么慢?

apache-flex - 我需要 Flex Builder 吗?

apache-flex - Flex 3 中 AIR 应用程序的峰值内存

flex3 - flex 3 遍历对象值

performance - AS3 中的快速 RSA 加密

apache-flex - 动态调用函数

javascript - 从客户发送电子邮件

apache-flex - 在 Flex 中反序列化二进制对象时,对象初始化是如何发生的?

apache-flex - 将 Ant 与 FlexBuilder 一起使用

apache-flex - 为什么 loaderInfo 仅在应用程序 Complete 触发后可用?