Solved

Align dynamic text within a movieclip in actionscript?

Posted on 2009-05-13
4
498 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…

751 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