![]() ![]() ![]() | |
![]() | |
![]() | |
![]() |
You can use the createTextField()
method of the MovieClip class to create an empty text field on the Stage at runtime. The new text field is attached to the Timeline of the movie clip that calls the method. The createTextField()
method uses the following syntax:
movieClip
.createTextField(instanceName
,depth
,x
,y
,width
,height
)
For example, the following code creates a 300 x 100 pixel text field named test_txt
at point (0,0) and a depth (z-order) of 10.
_root.createTextField("test_txt", 10, 0, 0, 300, 100);
You use the instance name specified in the createTextField()
call to access the methods and properties of the TextField class. For example, the following code creates a new text field named test_txt
, and then modifies its properties to make it a multiline, word-wrapping text field that expands to fit inserted text. Lastly, it assigns some text to the text field's text
property.
_root.createTextField("test_txt", 10, 0, 0, 100, 50); test_txt.multiline = true; test_txt.wordWrap = true; test_txt.autoSize = true; test_txt.text = "Create new text fields with the MovieClip.createTextField method.";
You can use the TextField.removeTextField()
method to remove a text field created with createTextField()
. The removeTextField()
method does not work on a text field placed by the Timeline during authoring.
For more information, see MovieClip.createTextField()
and TextField.removeTextField()
.
![]() | |
![]() | |
![]() | |
![]() ![]() ![]() |