Actionscript 3 as3文本字段格式问题

Actionscript 3 as3文本字段格式问题,actionscript-3,text,air,textformat,Actionscript 3,Text,Air,Textformat,我对文本字段的格式设置有问题。我有按钮+和-到文本的大小。TextField类具有用于新文本格式设置的属性defaultTextField。当我更改defaultTextFormat大小属性时,整个文本的大小也会更改。我到处寻找解决办法,但还没有找到。文本编辑器WISWYG(我不确定名称是否正确)在我遇到问题时,只需更改defaultTextFormat属性即可正常工作。也许这是因为flash和AIR之间的差异(flash上的编辑器和AIR上的我的应用程序)。请帮忙 此处是设置/获取文本格式的代

我对文本字段的格式设置有问题。我有按钮+和-到文本的大小。TextField类具有用于新文本格式设置的属性defaultTextField。当我更改defaultTextFormat大小属性时,整个文本的大小也会更改。我到处寻找解决办法,但还没有找到。文本编辑器WISWYG(我不确定名称是否正确)在我遇到问题时,只需更改defaultTextFormat属性即可正常工作。也许这是因为flash和AIR之间的差异(flash上的编辑器和AIR上的我的应用程序)。请帮忙

此处是设置/获取文本格式的代码:

    public function set selectionTextFormat(value:TextFormat):void {
        var begin:int = _textField.selectionBeginIndex;
        var end:int = _textField.selectionEndIndex;
        if (begin == end)
        {
            _textField.defaultTextFormat = value;
        }
        else
        {
            _textField.setTextFormat(value, begin, end);
        }
    }

    public function get selectionTextFormat():TextFormat 
    {
        var begin:int = _textField.selectionBeginIndex;
        var end:int = _textField.selectionEndIndex;
        if (begin == end)
        {
            return _textField.defaultTextFormat;
        }
        return  _textField.getTextFormat(begin, end);
    }
和更改格式的代码:

    private function setFormat(property:String, value:*):void
    {
        var tf:TextFormat = TextFormatter.TF.selectionTextFormat;
        tf[property] = value;
        TextFormatter.TF.selectionTextFormat = tf;
    }
编辑:用于说明的DROPBOX上的图像:

编辑2:我需要的图像(代码完全相同!)(所见即所得编辑器)

要更改将来键入的所有文本,可以尝试以下代码(结果可见):

当然,这只是一种做你想做的事情的方式,你必须使它适应你的需要并加以改进

var text_input:TextField = new TextField();
    text_input.border = true;
    text_input.type = 'input';
    text_input.text = 'hello world!';
addChild(text_input);

var new_fmt:TextFormat = new TextFormat();

btn_color.addEventListener(
    MouseEvent.CLICK, 
    function(e:MouseEvent):void {
        // set the new text color
        new_fmt.color = 0xFF0000;   
    }
)
btn_size.addEventListener(
    MouseEvent.CLICK, 
    function(e:MouseEvent):void {
        // set the new text size
        new_fmt.size = int(txt_size.text)       
    }
)

text_input.addEventListener(Event.CHANGE, function(e:Event):void {

    text_input.setTextFormat(new_fmt, text_input.caretIndex-1);

})