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:
// 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