document.addNewText()

可用性

Flash MX 2004;在 Flash CS3 Professional 中添加的可选 text 参数。

用法

document.addNewText(boundingRectangle [, text ])

参数

boundingRectangle 指定文本字段的大小和位置。有关 boundingRectangle 的格式的信息,请参阅 document.addNewRectangle()

text 一个可选字符串,它指定要在字段中放置的文本。如果省略此参数,则所选的"工具"面板将切换为"文本"工具。因此,如果不打算更改所选工具,请为 text 传递值。

返回

无。

说明

方法;插入新文本字段并且可以选择性地将文本放置到字段中。如果省略 text 参数,则可以调用 document.setTextString() 来填充文本字段。

示例

下面的示例在舞台的左上角创建一个新的文本字段,然后将该文本字符串设置为 "Hello World"

fl.getDocumentDOM().addNewText({left:0, top:0, right:100, bottom:100} , "Hello World!" );
fl.getDocumentDOM().setTextString('Hello World!'); 

另请参见

document.setTextString()