Redefine a function

I would like to redefine the information within moveHighlight once I go to another frame, and was wondering how to do this with as3. I want to leave all the if statements alone, I just need to change the variables.

This code needs to be really basic, so I can’t use classes or anthing like that.


function moveHighlight(event:Event = null) {


    if (highlightedButton == btn0) {
        if (moveUp == true) {
            trace("moveUp");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn3;
            targetPage = "page3";
            highlightedButton.gotoAndPlay("highlight");
            moveUp = false;
        }
        if (moveRight == true) {
            trace("moveRight");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn1;
            targetPage = "page2";
            highlightedButton.gotoAndPlay("highlight");
            moveRight = false;
        }
        if (moveDown == true) {
            trace("moveDown");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn1;
            targetPage = "page2";
            highlightedButton.gotoAndPlay("highlight");
            moveDown = false;
        }
        if (moveLeft == true) {
            trace("moveLeft");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn3;
            targetPage = "page3";
            highlightedButton.gotoAndPlay("highlight");
            moveLeft = false;
        }
        if (moveSelect == true) {
            trace("moveSelect");
            targetPage = "page2"
            highlightedButton.gotoAndPlay("rest");
            this.gotoAndStop(targetPage);
            //highlightedButton = btn0;
            //highlightedButton.gotoAndPlay("highlight");
            moveSelect = false;
        }
        if (moveConfirm == true) {
            trace("moveConfirm");
            this.gotoAndStop("page2");
            //highlightedButton.gotoAndPlay("rest");
            //highlightedButton = btn1;
            //highlightedButton.gotoAndPlay("highlight");
            moveConfirm = false;
        }
        if (moveBack == true) {
            trace("moveBack");
            this.gotoAndStop("page0");
            //highlightedButton.gotoAndPlay("rest");
            //highlightedButton = btn1;
            //highlightedButton.gotoAndPlay("highlight");
            moveBack = false;
        }
    }
}