# Navigation Script

**URL:** <https://forum.kirupa.com/t/navigation-script/248129>\
**Category:** flash\
**Created:** [January 4, 2008, 5:07am UTC](https://forum.kirupa.com/t/navigation-script/248129 "2008-01-04T05:07:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kdawg](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@kdawg](https://forum.kirupa.com/u/kdawg)\
**Post date:** [January 4, 2008, 5:07am UTC](https://forum.kirupa.com/t/navigation-script/248129/1 "2008-01-04T05:07:13Z")

</div>

I’m trying to streamline a script I wrote to navigate a small website. I used an array to assign button functions but I feel like the rest of the functionality could be more efficient as well. Anyone?

```auto

sectionFocus = "start";

//
// Rollover function
function secondaryRoll () {
    if (this.hitTest (_xmouse, _ymouse) == true) {
        this.gotoAndStop ("over");
    } else {
        this.gotoAndStop ("off");
    }
}

//
// Rollover reset
setSubnav = function () {
    if (sectionFocus != "home") {
        mainNav.home.onEnterFrame = secondaryRoll;
    }
    if (sectionFocus != "commercial") {
        mainNav.commercial.onEnterFrame = secondaryRoll;
    }
    if (sectionFocus != "interior") {
        mainNav.interior.onEnterFrame = secondaryRoll;
    }
    if (sectionFocus != "exterior") {
        mainNav.exterior.onEnterFrame = secondaryRoll;
    }
};

setSubnav ();

//
// Button Array
buttonArray = [];
buttonArray[0] = [mainNav.home, function () {
    gotoAndStop ("home");
    sectionFocus = "home";
    setSubnav ();
}];
buttonArray[1] = [mainNav.commercial, function () {
    gotoAndStop ("commercial");
    sectionFocus = "commercial";
    setSubnav ();
}];
buttonArray[2] = [mainNav.interior, function () {
    gotoAndStop ("interior");
    sectionFocus = "interior";
    setSubnav ();
}];
buttonArray[3] = [mainNav.exterior, function () {
    gotoAndStop ("exterior");
    sectionFocus = "exterior";
    setSubnav ();
}];

//
//
for (var i:Number = 0; i < buttonArray.length; i++) {
    buttonArray*[0].func = buttonArray*[1];
    buttonArray*[0].onPress = function () {
        this.onEnterFrame = this.func;
    };
    buttonArray*[0].onRelease = function () {
        delete this.onEnterFrame;
    };
}

stop ();

```
