Solved

Align dynamic text within a movieclip in actionscript?

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IE 11 Flash Player issue 7 249
AWAY 3d Using BitMapCubeTexture 1 425
Google Chrome Blank White Screens 13 303
I'm running a risk by using Adobe Flash in my site ? 9 123
This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
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…
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 how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

756 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