# One last question re: Dynamic text fields

**URL:** <https://forum.kirupa.com/t/one-last-question-re-dynamic-text-fields/219372>\
**Category:** flash\
**Created:** [March 15, 2007, 11:41pm UTC](https://forum.kirupa.com/t/one-last-question-re-dynamic-text-fields/219372 "2007-03-15T23:41:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pulykamell](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@pulykamell](https://forum.kirupa.com/u/pulykamell)\
**Post date:** [March 15, 2007, 11:41pm UTC](https://forum.kirupa.com/t/one-last-question-re-dynamic-text-fields/219372/1 "2007-03-15T23:41:11Z")

</div>

You guys have been great. I’m learning so much from this site and from the Foundation ActionScript book. One last question (at least for today) that I have:

I’m creating a dynamic menu. Basically, an array holds all the menu text, and I call a function to create a simple horizontal menu based on the size of the array. Pretty straightforward, the main code looks like this:

```auto

function buildMenu(number):Void {
    for (var i = 0; i<number; i++) {
        menu = this.attachMovie("mc_menu", "menu"+i, i);
        menu.menu_txt.text = menuArrays*;
        menu._x = MENUX-(i*MENUSPACING);
        menu._y = MENUY;
        menu.onRelease = sayHello;
    }

```

(sayHello is just a trace function to make sure the right instance is reporting to me.)

The problem is, the text fields are all of a fixed width, so a menu item with 10 letters in it will be just as wide as one with 1 letter in it. I’ve Googled, and I can’t seem to find a way of dynamically expanding and contracting text fields. Basically, what I would like to do is create a text field that is exactly as large as the text it contains, and for it to report to me its width so I can position menu items based on how far the actual text is from each other, rather than how far the fixed-width placeholders are from each other.

I don’t think there’s a property within text that will allow me to do this. Is there an object class that’s available to me that would help, or another way of solving this?
