Specify Styles for HTML in a TextField
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="1000" height="800" creationComplete="createStyle()">
<mx:Script>
private var styleText:String = '.largered { font-family:Arial, Helvetica;font-size:16; color: #ff0000; }' +
'.smallblue { font-size: 11; color: #0000ff; font-family:Times NewRoman, Times; }';
[Bindable]
private var lipsum:String = "<span class='largered'>Large</span>"+
" <span class='smallblue'>small</span>";
[Bindable]
private var style:StyleSheet;
private function createStyle():void
{
style = new StyleSheet();
style.parseCSS(styleText);
text.styleSheet = style;
text.htmlText = lipsum;
}
</mx:Script>
<mx:TextArea id="text" width="200" height="300"/>
</mx:Application>
Related examples in the same category