有三种方式对文本进行格式化:HTML标签格式化、使用TextFormat对象、CSS样式
* HTML标签格式化示例: textBox.htmlText = "<B>粗体文本</B><U>下划线文本</U>";
* TextFormat对象示例:(注意:只对setTextFormat之前的代码有效)
var textFormat:TextFormat = new TextFormat();
textFormat.color = 0xFF0000;
textFormat.htmlText = "有效";
//也可以对部分文字进行格式化,例如:textBox.setTextFormat(textFormat,3,textBox.text.length);
textBox.setTextFormat(textFormat); textFormat.htmlText = "无效";
* CSS样式示例:(注意:只对CSS定义之后的代码有效)
var css:StyleSheet = new StyleSheet();
var styleObj:Object = {color:"#FF0000"};
css.setStyle(".stdStyle",styleObj);
textBox.styleSheet = css;
textBox.htmlText = "不潮不用花钱";
this.addChild(textBox);