# getBounds() - Does it work with textfields?

**URL:** <https://forum.kirupa.com/t/getbounds-does-it-work-with-textfields/283761>\
**Category:** flash\
**Created:** [March 10, 2009, 8:42pm UTC](https://forum.kirupa.com/t/getbounds-does-it-work-with-textfields/283761 "2009-03-10T20:42:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![IanCremona](https://avatars.discourse-cdn.com/v4/letter/i/65b543/32.png) [@IanCremona](https://forum.kirupa.com/u/IanCremona)\
**Post date:** [March 10, 2009, 8:42pm UTC](https://forum.kirupa.com/t/getbounds-does-it-work-with-textfields/283761/1 "2009-03-10T20:42:52Z")

</div>

I’m trying to get the height of the (external) text in textfields to display them veritcally on top of eachother with a space in between

at the moment I am adding the textfields with predefined heights, so if item1 is 2 lines and item2 is 4 lines then there is a lot of space between item1 and item2

any suggestions?

```
ActionScript Code:
[LEFT][COLOR=#000000] **var** [/COLOR] my_tf = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000FF]TextField[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];

```

my\_tf.[COLOR=#0000FF]text[/COLOR] = [COLOR=#FF0000]“Hello”[/COLOR];  
my\_tf.[COLOR=#000080]appendText[/COLOR][COLOR=#000000]([/COLOR][COLOR=#FF0000]" world!"[/COLOR][COLOR=#000000])[/COLOR];[COLOR=#808080]\*// my\_tf.text == “Hello world!” \*[/COLOR]  
my\_tf.[COLOR=#000080]x[/COLOR] = [COLOR=#000080]100[/COLOR];  
addChildCOLOR=#000000[/COLOR];

addChild[COLOR=#000000]([/COLOR]createRectShape[COLOR=#000000]([/COLOR]my\_tf.[COLOR=#0000FF]getBounds[/COLOR]COLOR=#000000[/COLOR], 0xFF0000[COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR];

[COLOR=#000000] **function** [/COLOR] createRectShape[COLOR=#000000]([/COLOR]rect:Rectangle, [COLOR=#0000FF]color[/COLOR]:uint[COLOR=#000000])[/COLOR]:Shape [COLOR=#000000]{[/COLOR]  
[COLOR=#000000] **var** [/COLOR] rectShape:Shape = [COLOR=#000000] **new** [/COLOR] ShapeCOLOR=#000000[/COLOR];  
rectShape.[COLOR=#000080]graphics[/COLOR].[COLOR=#0000FF]lineStyle[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000080]0[/COLOR], [COLOR=#0000FF]color[/COLOR][COLOR=#000000])[/COLOR];  
rectShape.[COLOR=#000080]graphics[/COLOR].[COLOR=#000080]drawRect[/COLOR][COLOR=#000000]([/COLOR]rect.[COLOR=#0000FF]left[/COLOR], rect.[COLOR=#000080]top[/COLOR], rect.[COLOR=#0000FF]width[/COLOR], rect.[COLOR=#0000FF]height[/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#0000FF]return[/COLOR] rectShape;  
[COLOR=#000000]}[/COLOR]  
[/LEFT]
