开始把控件局限在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'>123456font 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>
您可能感兴趣的文章:- Flex CategoryAxis 字体样式修改
- Flex 关于字体的应用示例介绍