package {
import flash.text.TextField;
import flash.text.StyleSheet;
import flash.text.TextFieldAutoSize;
public class MyTF extends TextField {
public var
color:uint,
size:int
public function MyTF( color:uint, size:int) {
super();
color = color; // setting color and size
size = size;
init(); //initialize
}
private function init():void
{
autoSize = TextFieldAutoSize.LEFT;
var style:StyleSheet = new StyleSheet();
style.setStyle('span', {color: 0xFF0000, fontSize: 24});
styleSheet = style;
htmlText = '<span>test</span>';
//after creating an object of this class the text Style is not changing
}
}
}
为什么在创建此类的实例后htmlText样式没有改变?有什么不对吗?
答案 0 :(得分:0)
如果我没错,了解你可以帮助你:
style.setStyle('span', {color: 0xFF0000, fontSize: 24});
更改为
style.setStyle('span', {color: this.color, fontSize: this.size});
。