0
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 样式没有改变?有什么不对?

4

1 回答 1

0

如果我没记错的话,这可以帮助你:

style.setStyle('span', {color: 0xFF0000, fontSize: 24});更改为 style.setStyle('span', {color: this.color, fontSize: this.size});.

于 2012-12-23T11:05:22.980 回答