Align Text with ActionScript 3 - Center AS3 Text

Imports needed to align your Flash text in AS3.

import flash.text.TextField;
import flash.text.TextFieldAutoSize;
Alignments you can do with your text:
TextFieldAutoSize.LEFT
TextFieldAutoSize.RIGHT
TextFieldAutoSize.CENTER
TextFieldAutoSize.NONE
Syntax needed to align your dynamic text in AS3.
_textField.autoSize = TextFieldAutoSize.LEFT;
_textField.text = "Hello World!  This is my text.";
Make sure that you assign the autoSize before you set the text. If you set the text first the alignment will not work correclty.

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this post.
Comments
  • No comments exist for this post.
Leave a comment

Submitted comments are subject to moderation before being displayed.

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.