Actionscript 3 输入文本字段中的DefaulTextFormat

Actionscript 3 输入文本字段中的DefaulTextFormat,actionscript-3,apache-flex,Actionscript 3,Apache Flex,这是我的密码 var format:TextFormat=new TextFormat(); var text:TextField=new TextField(); text.border=true; text.width=400; text.multiline=true; text.wordWrap=true; text.type=TextFieldType.INPUT; text.background=true; text.text="Some text"; // Bold doesn

这是我的密码

var format:TextFormat=new TextFormat(); 
var text:TextField=new TextField();
text.border=true;
text.width=400;
text.multiline=true;
text.wordWrap=true;

text.type=TextFieldType.INPUT;
text.background=true;

text.text="Some text"; // Bold doesn't works with this line

format.bold=true;
text.defaultTextFormat=format;

输入文本字段不为空时,我无法格式化文本。如何解决此问题或我的错误是什么?

尝试调用setTextFormat,您可能会看到


问题出在
defaultTextFormat
中。正如参考文献所说

指定应用于新插入文本(如文本)的格式 由用户输入或用replaceSelectedText()插入的文本 方法


尝试使用
text.setTextFormat(格式)

首先设置
defaultTextFormat
,然后设置
text

format.bold=true;
text.defaultTextFormat=format;
text.text="Some text"; // Should now be bold
format.bold=true;
text.defaultTextFormat=format;
text.text="Some text"; // Should now be bold