Flex中实现对一个text渲染不同的字体颜色
开始把控件局限在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'>易做图</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>
补充:综合编程 , 其他综合 ,