-
dynamicly center text box
I need to keep a text box centered in the middle of the stage (horizontaly) no matter how wide the text box is (it will get bigger and smaller dynamically).
I also need:
How can I get a dynamic text box to always display the text at the bottom?
Similar to the "align bottom" with a cell in a table.
any help would be great.
Beyond Flash
Your one stop web shop
http://www.beyondflash.net
-
Senior Member
The basic forumula for keeping something centered is:
thing._x = (Stage.width - thing._width)/2;
or, if you've precomputed the center coordinate, you can use:
centerCoordinate = Stage.width/2;
thing._x = centerCoordinate - thing._width/2;
If the text box is contained inside a movieclip, you can use the movieclip width. Otherwise, you can set the textfield to autosize and use the textWidth property instead of thing._width.
The basic forumula for keeping something bottom-aligned is:
thing._y = bottomCoordinate - thing._height;
Again, you can either contain the textfield in a movieclip, and use the movieclip height, or you can set the textfield to autosize and use the textHeight property.
-
How would I go about using the texthight property?
Beyond Flash
Your one stop web shop
http://www.beyondflash.net
-
Senior Member
Let's say your textfield is called myText.
When you initialize it, you set autoSize to true:
myText.text = 'initial text';
myText.autoSize = true;
When you change it, the textHeight property will tell you how tall it is.
myText.text = 'changed text';
myText._y = 200 - myText.textHeight;
-
Got it
Thank you very much!!
Beyond Flash
Your one stop web shop
http://www.beyondflash.net
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|