使用如下样式属性会<span>的样式: "<span class='largered'> This style is specified in the string that will be passed to the StyleSheet.parseStyle method: .largered { font-family:Arial, Helvetica; font-size:16; color: #ff0000; } 例子:
+展开
-XML
<mx:Applicationxmlns:mx="http://www.adobe.com/2006/mxml" width="1000" height="800" creationComplete="createStyle()"> <mx:Script> <![CDATA[ //note even though names are camel cased here when used, all lowercase privatevar styleText:String = '.largered { fontfamily: Arial, Helvetica; font-size:16; color: #ff0000; }' + '.smallblue { font-size: 11; color: #0000ff; font-family:Times New Roman, Times; }' + 'li { color:#00ff00; font-size:14; }' + 'ul {margin-left:50px;}'; [Bindable] privatevar lipsum:String = "<span class='largered'>Nulla metus.</span> Nam ut dolor vitae risus condimentum auctor."+ " <span class='smallblue'>Cras sem quam,</span> malesuada eu, faucibus aliquam, dictum ac, dui. Nullam blandit"+ " ligula sed arcu. Fusce nec est.<ul><li> Etiam</li><li> aliquet,</li> <li>nunc</li></ul> eget pharetra dictum, magna"+ " leo suscipit pede, in tempus erat arcu et velit. Aenean condimentum. Nunc auctor"+ " nulla vitae velit imperdiet gravida"; [Bindable] privatevar style:StyleSheet; privatefunction createStyle():void { style = new StyleSheet(); style.parseCSS(styleText); text.styleSheet = style; text.htmlText = lipsum; }