Create text instance code dynamically using as

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.