|
|
|
#1 |
|
Member
Join Date: Jul 2002
Location: New Mexico
Posts: 83
|
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 |
|
|
|
|
|
#2 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
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. |
|
|
|
|
|
#3 |
|
Member
Join Date: Jul 2002
Location: New Mexico
Posts: 83
|
How would I go about using the texthight property?
__________________
Beyond Flash Your one stop web shop http://www.beyondflash.net |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Feb 2004
Location: Los Angeles
Posts: 2,920
|
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; |
|
|
|
|
|
#5 |
|
Member
Join Date: Jul 2002
Location: New Mexico
Posts: 83
|
Got it
Thank you very much!!
__________________
Beyond Flash Your one stop web shop http://www.beyondflash.net |
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|