ActionScript Warning: 3551:

ActionScript Warning: 3551: Appending text to a TextField using += is many times slower than using the TextField.appendText() method.

ActionScript Error Description:
I love this ActionScript Warning. This is not technically an ActionScript Error instead it is a warning that helps you code better. It is very clear and easily deciphered. This states that you should not use the old way to add text to a text field but rather use the new TextField.appendText() method. This improves performance dramatically and will prevent the user from getting the 15 sec. timeout. (Error #1502: A script has executed for longer than the default timeout period of 15 seconds.)

Fix:
Use TextField.appendText() instead of +=.

Bad Code:

    var something:String = "Happy ";
    var somethingElse:String = "Birthday";
    myTF_txt.text = something;
    myTF_txt.text += somethingElse;

Good Code:

    var something:String = "Happy ";
    var somethingElse:String = "Birthday";
    myTF_txt.text = something;
    myTF_txt.appendText(somethingElse);

About Judah

Please note in the comments if this has helped you or not.
This entry was posted in Compiler Warnings. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Highlight your code before posting code:

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="">