Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 04-06-2012, 06:50 PM   #1
Join Date: Apr 2012
Posts: 52
Default Align dynamic text field?

Is it possible to align a dynamic textfield with AS3? I was surprised I didn't find any working results when googling this...
I've tried txt.align = "right" but that gives some error saying "1119: Access of possibly undefined property align through a reference with static type flash.text:TextField", yet "align" is highlighted in blue which I assume means it exists? Trying "TextFormatAlign.RIGHT" gives the same "undefined property" error.
I need a simple method to do this, my text field instance name is "txt".

Last edited by LanLing; 04-06-2012 at 06:53 PM.
LanLing is offline   Reply With Quote
Old 04-06-2012, 08:26 PM   #2
Senior Member
Join Date: Apr 2005
Location: st louis, MO
Posts: 167
Default You need to create a text format

ActionScript Code:
//This is the section for our text styling, first we create a TextFormat instance naming it myFormat  var myFormat:TextFormat = new TextFormat();    //Giving the format a hex decimal color code  myFormat.color = 0xAA0000;    myFormat.align = TextFormatAlign.RIGHT;   //Adding some bigger text size  myFormat.size = 24;    //Last text style is to make it italic.  myFormat.italic = true;    //Now the most important thing for the textformat, we need to add it to the myTextField with setTextFormat.  myTextField.setTextFormat(myFormat);
caseyctg is offline   Reply With Quote
Old 04-06-2012, 10:10 PM   #3
Super Moderator
ASWC's Avatar
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,742

ActionScript Code:
this sets the textformat for the current text. To set a textformat for all text you might set this textfield with later on use:
ActionScript Code:
myTextField.defaultTextFormat = myFormat;
Super Duper!
ASWC is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 05:45 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.