DefaultTextFormat vs SetTextFormat

后端 未结 1 1543
梦毁少年i
梦毁少年i 2021-01-21 14:22

here are 2 code blocks.

var myTextField:TextField = new TextField();
var myTextFormat:TextFormat = new TextFormat();

addChild(myTextField);

myTextFormat.font          


        
相关标签:
1条回答
  • 2021-01-21 15:12

    setTextFormat allows you to change the formatting on parts of the text. Check out the other two parameters of setTextFormat. When you set defaultTextFormat it is applied to all the text that you add to the TextField.

    More info :

    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextField.html#defaultTextFormat

    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextField.html#setTextFormat

    Edit : Also setTextFormat doesn't work on text that is inserted after you set the format. Adobe says "Any text inserted manually by the user, or replaced by the replaceSelectedText() method, receives the default text field formatting for new text, and not the formatting specified for the text insertion point. To set the default formatting for new text, use defaultTextFormat."

    0 讨论(0)
提交回复
热议问题