# Menu from array - sizing problem

**URL:** https://forum.kirupa.com/t/menu-from-array-sizing-problem/64375
**Category:** Uncategorized
**Created:** [September 15, 2004, 4:52pm UTC](https://forum.kirupa.com/t/menu-from-array-sizing-problem/64375 "2004-09-15T16:52:04Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![shuga](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@shuga](https://forum.kirupa.com/u/shuga)
#### Post date: [September 15, 2004, 4:52pm UTC](https://forum.kirupa.com/t/menu-from-array-sizing-problem/64375/1 "2004-09-15T16:52:04Z")

</div>

I’m trying to create a menu from an array and I have the script working except for one little thing. all my buttons are the same size but my text is nowhere near the same length.

I’m trying to detect the length of each item in the array ‘nav2’ and set the width of the subsequently created clip to a funciton of that number probably something like (num\*8)+20 so that each button is 10 px bigger on each size than the number of letters on the button

I think I have the right idea when I call for the width to be (\_root.nav2\*length) but the syntax is wrong. although I could be wrong altogether.

I also intend to use this number for the \_x of the buttons so they’re evenly spaced.

Here’s the script:

```auto

// format the text of the buttons
myFormat = new TextFormat();
myFormat.font = "Arial";
myFormat.size = 14;
myFormat.color = 0xFFFFFF;
myFormat.indent = 3;
myFormat.bold = 0;
myFormat.align = "center";
var nav2 = ["News", "About", "Menus", "Koki Club", "Schmoock's Net", "Events", "Location", "Banquets", "Gallery"];
// create the menu with the names from the array above
for (i=0; i<nav2.length; i++) {
	_root.createEmptyMovieClip("mc"+i, i+20);
	with (_root["mc"+i]) {
		createTextField("label", 1003, 85*i, 82, (_root.nav2*length), 19);
		with (label) {
			background = false;
			border = true;
			bordercolor = 0xFFFFFF;
			type = "dynamic";
			text = _root.nav2*;
			selectable = false;
			setTextFormat(myFormat);
			align = center;
		}
	}

```

thanks for your help

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 15, 2004, 6:09pm UTC](https://forum.kirupa.com/t/menu-from-array-sizing-problem/64375/2 "2004-09-15T18:09:37Z")

</div>

inacse anyone ever reads this i figured it out

```auto

//-------------------------------
//create the second level menu
//-------------------------------
// format the text of the buttons
myFormat = new TextFormat();
myFormat.font = "Arial";
myFormat.size = 14;
myFormat.color = 0xFFFFFF;
myFormat.indent = 3;
myFormat.bold = 0;
myFormat.align = "center";
var nav2 = ["News", "About", "Menus", "Koki Club", "Schmoock's Net", "Events", "Location", "Banquets", "Gallery"];
// create the menu with the names from the array above
pos2 = 0;
wid2 = 0;
for (i=0; i<nav2.length; i++) {
	_root.createEmptyMovieClip("n2"+i, i+20);
	with (_root["n2"+i]) {
		wid2 = ((_root.nav2*.length)*8)+20;
		createTextField("label", 1003, pos2, 26, wid2, 19);
		with (label) {
			background = false;
			border = false;
			type = "dynamic";
			text = _root.nav2*;
			selectable = false;
			setTextFormat(myFormat);
			align = center;
		}
		pos2 = pos2+wid2;
	}

```
