Solved

Align dynamic text within a movieclip in actionscript?

Posted on 2009-05-13
4
500 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

623 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