# Array Nav Distribution

**URL:** <https://forum.kirupa.com/t/array-nav-distribution/256441>\
**Category:** flash\
**Created:** [April 3, 2008, 1:19am UTC](https://forum.kirupa.com/t/array-nav-distribution/256441 "2008-04-03T01:19:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tyg3r](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/tyg3r/32/1341_2.png) [@Tyg3r](https://forum.kirupa.com/u/Tyg3r)\
**Post date:** [April 3, 2008, 1:19am UTC](https://forum.kirupa.com/t/array-nav-distribution/256441/1 "2008-04-03T01:19:19Z")

</div>

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.

```auto
// 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
 };
}

```
