Align dynamic text within a movieclip in actionscript?

I have a movieclip "square" with another movieclip "text" inside.  Inside "text" is a dynamic textfield called "char_txt". "char_txt" is a single character.   "square" is exactly that a graphic square.  I need "char_txt" to align in the middle of the square so that no matter the font or size of the text, it will always land in the center of the square.  

el_suavoAsked:
Who is Participating?
 
rascalpantsConnect With a Mentor Commented:

then the only way to do this is to figure out how many characters will fit at all of the possible sizes...   then you can do a string length to find the number and then based on the size you want, position the textfield vertically(y position)...

will the text have to go to 2 or 3 lines?  if so, you will need to figure that into your algorithm as well.


I would still use center alignment in the text field, just so you don't have to calculate the X position of the text field.


rp / ZA
0
 
rascalpantsCommented:

my favorite way to handle this is to center align the dynamic text field.

no programming required.  :)



rp / ZA
0
 
el_suavoAuthor Commented:
Center align works horizontally, but I need it to align vertically as well (i.e. middle justification).
0
 
rascalpantsCommented:

^ bump ^
 

please come back and finish up this question...


thanks,

rp / Zone Advisor
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.