This article for you in detail how to achieve the next flex in a text rendering different font color, the specific implementation of ideas and code as follows, interested friends can refer to ha, I hope to help you
Beginning to confine the control to the label, it seems unrealistic to realize that. You should use the TEXTAREA control:
Copy Code code as follows:
<?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= "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 = "I am Chinese, I am Chinese, I am Chinese";
}
]]>
</fx:Script>
<mx:canvas x= "y=" width= "$" > "height="
<s:text Area id= "TXT" >
</s:TextArea>
</mx:Canvas>
</s:application>