# Button naming and positioning

**URL:** https://forum.kirupa.com/t/button-naming-and-positioning/229450
**Category:** Uncategorized
**Created:** [June 17, 2007, 11:44am UTC](https://forum.kirupa.com/t/button-naming-and-positioning/229450 "2007-06-17T11:44:24Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![g5604](https://avatars.discourse-cdn.com/v4/letter/g/54ee81/32.png) [@g5604](https://forum.kirupa.com/u/g5604)
#### Post date: [June 17, 2007, 11:44am UTC](https://forum.kirupa.com/t/button-naming-and-positioning/229450/1 "2007-06-17T11:44:24Z")

</div>

Hi,

I am trying to assign meaningful names to buttons in a for loop based of the var mainBtn.mName. This would normally be easy but i need to to get the width of the buttons before it (the bold code) to work out the position of each button, any ideas how i can do this?

```auto

for (i=0; i<folder.length; i++) {
            var mainBtn:MovieClip = mainMenu.attachMovie("button", "button"+i, i);
            mainBtn.mName = folder*.attributes.name;
            **mainBtn._x += mainMenu["button"+(i-1)]._x+mainMenu["button"+(i-1)]._width+btnSpacing**;

```
