One last question re: Dynamic text fields

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:


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?