Solved

Align dynamic text within a movieclip in actionscript?

Posted on 2009-05-13
4
493 Views
Last Modified: 2013-11-11
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.  

0
Comment
Question by:el_suavo
  • 3
4 Comments
 
LVL 22

Expert Comment

by:rascalpants
ID: 24380304

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

no programming required.  :)



rp / ZA
0
 

Author Comment

by:el_suavo
ID: 24380552
Center align works horizontally, but I need it to align vertically as well (i.e. middle justification).
0
 
LVL 22

Accepted Solution

by:
rascalpants earned 500 total points
ID: 24385464

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
 
LVL 22

Expert Comment

by:rascalpants
ID: 24436037

^ bump ^
 

please come back and finish up this question...


thanks,

rp / Zone Advisor
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now