开始把控件局限在label上,发现实现起来似乎不太现实。应该用textarea控件:
复制代码 代码如下:
<?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" minWidth="955" minHeight="600" creationComplete="inital();">
<fx:script>
<![CDATA[
import flashx.textLayout.conversion.TextConverter;
public function inital():void{
var str:String = "<font color='#ff0000'>123456<font color='#32CD32'>shit</font></font>";
txt.textFlow = TextConverter.importToFlow(str, TextConverter.TEXT_FIELD_HTML_FORMAT);
//txtArea.text = "我是中国人我是中国人我是中国人我是中国人";
}
]]>
</fx:script>
<mx:Canvas x="300" y="300" width="500" height="500">
<s:TextArea id="txt">
</s:TextArea>
</mx:Canvas>
</s:Application>
复制代码 代码如下:
<?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" minWidth="955" minHeight="600" creationComplete="inital();">
<fx:script>
<![CDATA[
import flashx.textLayout.conversion.TextConverter;
public function inital():void{
var str:String = "<font color='#ff0000'>123456<font color='#32CD32'>shit</font></font>";
txt.textFlow = TextConverter.importToFlow(str, TextConverter.TEXT_FIELD_HTML_FORMAT);
//txtArea.text = "我是中国人我是中国人我是中国人我是中国人";
}
]]>
</fx:script>
<mx:Canvas x="300" y="300" width="500" height="500">
<s:TextArea id="txt">
</s:TextArea>
</mx:Canvas>
</s:Application>
本文章来源于网络,作者是:,由代码部落进行采编,如涉及侵权请联系删除!转载请注明出处:https://daimabuluo.cc/flex/1339.html