Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 04-06-2012, 06:50 PM   #1
LanLing
Member
 
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".
Thanks.

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
caseyctg
Senior Member
 
Join Date: Apr 2005
Location: st louis, MO
Posts: 160
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
ASWC
Super Moderator
 
ASWC's Avatar
 
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,528
Default

ActionScript Code:
myTextField.setTextFormat(myFormat);
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;
__________________
aswebcreations
Super Duper!
ASWC is offline   Reply With Quote
Reply


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 06:37 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, 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.