Select File > New, and then select Flash Document to create a new FLA file.
Type the following ActionScript:this.createTextField on frame 1th of the timeline ("Test_txt", 10, 0, 0, 300, 100);
This code creates a text field named Test_txt x 100 pixels in the position (0, 0) point, depth (Z-order) of 10.
To access the methods and properties of the newly created text field, use the instance name specified in the 1th parameter of the Createtextfield () method.
For example, the following code creates a new text field named Test_txt, and then modifies its properties to make it a multiline, newline-wrapped text field that can be adjusted based on the length of the inserted text. The code then assigns text using the Text property of the literal field:
The code is as follows |
Copy Code |
Test_txt.multiline = true; Test_txt.wordwrap = true; Test_txt.autosize = "Left"; Test_txt.text = "Create new text fields with the Movieclip.createtextfield () method."; |
Select Control > Test movie to view the text field.
Text that you create at run time will appear on the stage.