利用RichText动态加载带格式的字符串
利用RichText动态加载带格式的字符串,如:
<p>The quick brown <span color="#ff0000">fox jumps over</span> the lazy dogg.</p>
<?xml version="1.0" encoding="utf-8"?> <!-- http://blog.flexexamples.com/2009/08/11/setting-text-in-a-spark-richtext-control-in-flex-4/ --> <s:Application name="Spark_RichText_text_test" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo"> <fx:Script> <![CDATA[ import spark.utils.TextFlowUtil; protected function button1_clickHandler(event:MouseEvent):void { // TODO Auto-generated method stub var d:String = '<p>The quick brown <span color="#ff0000">fox jumps over</span> the lazy dogg.</p>'; richTxt.textFlow = TextFlowUtil.importFromString(d); } ]]> </fx:Script> <fx:Declarations> <fx:String id="htmlTextAsMarkup"><![CDATA[<p>The quick brown <span fontWeight="bold">fox jumps over</span> the lazy dogg.</p>]]></fx:String> </fx:Declarations> <!-- <s:RichText id="richTxt" textFlow="{TextFlowUtil.importFromString(htmlTextAsMarkup)}" horizontalCenter="0" verticalCenter="0" />--> <s:RichText id="richTxt" horizontalCenter="0" verticalCenter="0" /> <s:Button x="34" y="32" label="按钮" click="button1_clickHandler(event)"/> </s:Application>
更多选择,请查看链接:http://blog.flexexamples.com/2009/08/11/setting-text-in-a-spark-richtext-control-in-flex-4/
相关推荐
liqing 2020-04-18
wulaxiaohei 2020-02-20
lightlanguage 2020-02-18
sixthelement 2020-01-13
impress 2020-01-01
lionelf 2014-06-03
zxznsjdsj 2019-10-20
zhuyonge 2016-05-19
helloworlddm 2010-12-15
faiculty 2011-12-18
Stephenmu 2014-08-19
lionelf 2014-06-03
LetonLIU 2013-09-16
Godfavoredone 2019-06-28
黎俊杰的DBA生涯 2011-09-29
panpanhappy 2015-06-28
88251546 2015-03-28
DwyaneCoding 2013-07-30