I’ve been working on a Navigator that uses an Array to get it’s information. I’ve used countless scripts from countless threads and have managed to produced a simple Vertical menu.
Problem is, I need it to be Horizontal. The bigger problem is, I wanted the buttons to distribute evenly. I can’t figure out how to tell Flash to calculate the various widths of the buttons and align them horizontally… with a little bit of spacing too. Any help would be greatly appriciated.
// Button Array
var buttonArray:Array = new Array("home", "about", "services", "prices", "contact");
/////// Button Menu ////////
function RollOver(btnInfo) {
var button = this[btnInfo];
newColour = new Color(button.bg);
newColour.setRGB(0xE4C5C5);
}
function RollOut(btnInfo) {
var button = this[btnInfo];
newColour = new Color(button.bg);
newColour.setRGB(0xFFFFFF);
}
for (var i = 0; i<buttonArray.length; i++) {
attachMovie("button","menuBar",this.getNextHighestDepth()); //Places button onto stage
var menuSizeVar = menuBar._height*buttonArray.length+(2*buttonArray.length); // Calculates spacing and positioning
var Align = i*(menuBar._height+2)-menuSizeVar; // Aligns the buttons vertically
duplicate = menuBar.duplicateMovieClip("btn"+i, i, {_y:Align}); // Creates buttons according to the array
this["btn"+i].btnText.text = buttonArray*; //Places text into the buttons accroding to the array
this["btn"+i].btnText.autoSize = true;// Allow textbox to reseize
this["btn"+i].bg._width = this["btn"+i].btnText._width+10;// Make button background the same width as the text
this["btn"+i].btnAndNum = ["btn"+i]; //Creates a Paramater for later on
//Rollover Button
this["btn"+i].onRollOver = function() {
RollOver(this.btnAndNum); // uses the paramaters to create a function
};
//Rolloff Button
this["btn"+i].onRollOut = this["btn"+i].onReleaseOutside=function () {
RollOut(this.btnAndNum); // uses the paramaters to create a function
};
}