# Getting a bunch of 1009 errors

**URL:** <https://forum.kirupa.com/t/getting-a-bunch-of-1009-errors/306943>\
**Category:** flash\
**Created:** [March 24, 2010, 10:47pm UTC](https://forum.kirupa.com/t/getting-a-bunch-of-1009-errors/306943 "2010-03-24T22:47:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hausnfranz](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/hausnfranz/32/2427_2.png) [@Hausnfranz](https://forum.kirupa.com/u/Hausnfranz)\
**Post date:** [March 24, 2010, 10:47pm UTC](https://forum.kirupa.com/t/getting-a-bunch-of-1009-errors/306943/1 "2010-03-24T22:47:40Z")

</div>

I know this is a bit of code, but some of these errors are really hard to understand exactly what they are telling me :

This error happens when I go from one frame to the next, where there is code in both places.  
**TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at page0/frame11()  
at flash.display::MovieClip/gotoAndStop()  
at page0/moveHighlight0()  
at page0/onReceiveAnalogData()  
at flash.events::EventDispatcher/dispatchEventFunction()  
at flash.events::EventDispatcher/dispatchEvent()  
at net.eriksjodin.arduino::Arduino/processData()  
at net.eriksjodin.arduino::Arduino/socketDataHandler()**

When I try to debug I am also getting a security error :

> 

Attemping to launch and connect to Player using URL C:\Documents and Settings  
ame\Desktop\arduino\_flash\_files\joystick\_flash\_codev4.swf  
[SWF] C:\Documents and Settings  
ame\Desktop\arduino\_flash\_files\joystick\_flash\_codev4.swf - 508274 bytes after decompression  
SecurityError: Error #2010: Local-with-filesystem SWF files are not permitted to use sockets.  
at [flash.net](http://flash.net)::Socket/internalConnect()  
at [flash.net](http://flash.net)::Socket/connect()  
at net.eriksjodin.arduino::Arduino()[C:\Documents and Settings  
ame\Desktop\arduino\_flash\_files  
et\eriksjodin\arduino\Arduino.as:100]  
at page0/frame1()[page0::frame1:8]  
Cannot display source code at this location.

There is code on two layers in frame one, one is for global, and the other is for frame specific stuff.

Global code layer :

```auto

stop();

//arduino code
import net.eriksjodin.arduino.Arduino;
import net.eriksjodin.arduino.events.ArduinoEvent;
//import flash.events.Event;

var arduino:Arduino=new Arduino("127.0.0.1",5331);
arduino.setAnalogPinReporting(0, Arduino.ON);
arduino.setAnalogPinReporting(1, Arduino.ON);
arduino.setAnalogPinReporting(3, Arduino.ON);
arduino.setAnalogPinReporting(2, Arduino.ON);
arduino.setAnalogPinReporting(4, Arduino.ON);
arduino.setAnalogPinReporting(5, Arduino.ON);

arduino.addEventListener(ArduinoEvent.ANALOG_DATA, onReceiveAnalogData);

//triggers if statements on "page actions" code layer
//MUST be set for each button on each page
var moveZUp=false;
var moveZDown=false;
var moveUp=false;
var moveRight=false;
var moveDown=false;
var moveLeft=false;
var moveConfirm=false;
var moveBack=false;
var moveSelect=false;
var joyRest=true;

//restricts receiving analog data to a single axis
var movingX = false;
var movingY = false;
var movingZ = false;

var btnPressed = false;

//MUST BE SPECIFIED FOR EACH PAGE FRAME on "page actions" code layer
//sets which button is default highlight
var highlightedButton=btn3;
//sets which page to go to if button is selected
var targetPage="page1";
//allows "page actions" function for each page to work
var currentPage="page0";
//think this var is legacy, may delete
var joyDir="rest";

//triggers smoothMove function
var smoothZUp = false;
var smoothZDown = false;
//allows constant movement if joystick is held down on certain pages :
//Docking Zaxis page
addEventListener(Event.ENTER_FRAME, smoothMove);  
function smoothMove(event:Event) { 

    if (smoothZUp == true) {
        btn8.y = btn8.y - 3;
        
    } else if (smoothZDown == true) {
        btn8.y = btn8.y + 3;
        
    } else {
        //do nothing
    }
}

function onReceiveAnalogData(e:ArduinoEvent):void {
    if (e.pin==1) {
        if (e.value>500){
            if (joyRest == true) {
                if (btnPressed == false) {
                    trace("backBtn pressed");
                    btnPressed = true;
                    moveBack = true;
                    if (currentPage=="page0") {
                        moveHighlight0();
                    } else if (currentPage == "page1") {
                        moveHighlight1();
                    } else if (currentPage == "page2") {
                        moveHighlight2();
                    } else if (currentPage == "page3") {
                        moveHighlight3();
                    } else if (currentPage == "page4") {
                        moveHighlight4();
                    } else if (currentPage == "page5") {
                        moveHighlight5();
                    } else if (currentPage == "page6") {
                        moveHighlight6();
                    }
                    
                }
            }
        } else {
            btnPressed = false;
        }
    } else if (e.pin ==2) {
        if (e.value>500){
            if (joyRest == true) {
                if (btnPressed == false) {
                    trace("confirmBtn pressed");
                    btnPressed = true;
                    moveConfirm = true;
                    if (currentPage=="page0") {
                        moveHighlight0();
                    } else if (currentPage == "page1") {
                        moveHighlight1();
                    } else if (currentPage == "page2") {
                        moveHighlight2();
                    } else if (currentPage == "page3") {
                        moveHighlight3();
                    } else if (currentPage == "page4") {
                        moveHighlight4();
                    } else if (currentPage == "page5") {
                        moveHighlight5();
                    } else if (currentPage == "page6") {
                        moveHighlight6();
                    }
                }
            }
        }else {
            btnPressed = false;
        }
    } else if (e.pin==4) {
        if (e.value>500){
            if (joyRest == true) {
                if (btnPressed == false) {
                    trace("selectBtn pressed");
                    btnPressed = true;
                    moveSelect = true;
                    if (currentPage=="page0") {
                        moveHighlight0();
                    } else if (currentPage == "page1") {
                        moveHighlight1();
                    } else if (currentPage == "page2") {
                        moveHighlight2();
                    } else if (currentPage == "page3") {
                        moveHighlight3();
                    } else if (currentPage == "page4") {
                        moveHighlight4();
                    } else if (currentPage == "page5") {
                        moveHighlight5();
                    } else if (currentPage == "page6") {
                        moveHighlight6();
                    }
                    
                }
            }
        }else {
            btnPressed = false;
        }
        
    //left right axis
    } else if (e.pin==0) {

        //check to see if another direction is happening
        if (movingY == false && movingZ == false) {
            
            //left analoge range
            if (e.value<450) {
            
                //check to see that joystick is centered
                if (joyRest==true) {
                    
                    //restrict receiving analog data to x-axis only
                    movingX = true;
                    
                    //say that joystick is moving
                    joyRest=false;
                    trace("joyLeft");
                    
                    //activates if statement on "page actions"
                    moveLeft=true;

                    //figure out how to rewrite a function, this is sloppy
                    //function based on focused page
                    if (currentPage=="page0") {
                        moveHighlight0();
                    } else if (currentPage == "page1") {
                        moveHighlight1();
                    } else if (currentPage == "page2") {
                        moveHighlight2();
                    } else if (currentPage == "page3") {
                        moveHighlight3();
                    } else if (currentPage == "page4") {
                        moveHighlight4();
                    } else if (currentPage == "page5") {
                        moveHighlight5();
                    } else if (currentPage == "page6") {
                        moveHighlight6();
                    }
                }

            //right analoge range
            } else if (e.value > 550) {
                
                //Checks to see that joystick is centered
                if (joyRest==true) {
                    
                    //restrict receiving analog data to x-axis only
                    movingX = true;
                    
                    //say that joystick is moving
                    joyRest=false;
                    trace("joyRight");
                
                    //activates if statement on "page actions"
                    moveRight=true;

                    //figure out how to rewrite a function, this is sloppy
                    //function based on focused page
                    if (currentPage=="page0") {
                        moveHighlight0();
                    } else if (currentPage == "page1") {
                        moveHighlight1();
                    } else if (currentPage == "page2") {
                        moveHighlight2();
                    } else if (currentPage == "page3") {
                        moveHighlight3();
                    } else if (currentPage == "page4") {
                        moveHighlight4();
                    } else if (currentPage == "page5") {
                        moveHighlight5();
                    } else if (currentPage == "page6") {
                        moveHighlight6();
                    }
                }
            
            //rest analog range
            } else if (e.value >= 470 && e.value <= 530) {
                
                //allow receiving analog data to all axis again
                movingX = false;
                
                //joystick returned to center
                //allow another direction to be triggered
                joyRest=true;
                
                moveZUp = false;
                moveZDown = false;
                moveLeft=false;
                moveRight=false;
                moveUp=false;
                moveDown=false;
            }
        }
        
        
    } else if (e.pin==3) {

        //check to see if another direction is happening
        if (movingX == false && movingZ == false) {
            
            //up analoge range
            if (e.value<450) {
            
                //Checks to see that joystick is centered
                if (joyRest==true) {
                
                    //restrict receiving analog data to y-axis only
                    movingY = true;
                
                    //say that joystick is moving
                    joyRest=false;
                    trace("joyUp");
                
                    //activates if statement on "page actions"
                    moveUp=true;

                    //figure out how to rewrite a function, this is sloppy
                    //function based on focused page
                    if (currentPage=="page0") {
                        moveHighlight0();
                    } else if (currentPage == "page1") {
                        moveHighlight1();
                    } else if (currentPage == "page2") {
                        moveHighlight2();
                    } else if (currentPage == "page3") {
                        moveHighlight3();
                    } else if (currentPage == "page4") {
                        moveHighlight4();
                    } else if (currentPage == "page5") {
                        moveHighlight5();
                    } else if (currentPage == "page6") {
                        moveHighlight6();
                    }
                }
                
                
            } else if (e.value > 550) {
                
                //Checks to see that joystick is centered
                if (joyRest==true) {
                    
                    //restrict receiving analog data to y-axis only
                    movingY = true;
                    
                    //say that joystick is moving
                    joyRest=false;
                    trace("joyDown");
                    
                    //activates if statement on "page actions"
                    moveDown=true;

                    //figure out how to rewrite a function, this is sloppy
                    //function based on focused page
                    if (currentPage=="page0") {
                        moveHighlight0();
                    } else if (currentPage == "page1") {
                        moveHighlight1();
                    } else if (currentPage == "page2") {
                        moveHighlight2();
                    } else if (currentPage == "page3") {
                        moveHighlight3();
                    } else if (currentPage == "page4") {
                        moveHighlight4();
                    } else if (currentPage == "page5") {
                        moveHighlight5();
                    } else if (currentPage == "page6") {
                        moveHighlight6();
                    }
                }
    
            //rest analog state
            } else if (e.value >= 470 && e.value <= 530) {
                
                //allow receiving analog data to all axis again
                movingY = false;
                
                //joystick returned to center
                //allow another direction to be triggered
                joyRest=true;
                
                moveZUp = false;
                moveZDown = false;
                moveLeft=false;
                moveRight=false;
                moveUp=false;
                moveDown=false;
            }
        }
    } 
    //left right axis
    if (e.pin==5) {

        //check to see if another direction is happening
        if (movingX == false && movingY == false) {
            
            //left analoge range
            if (e.value<450) {
            
                //check to see that joystick is centered
                if (joyRest==true) {
                    
                    //restrict receiving analog data to x-axis only
                    movingZ = true;
                    
                    //say that joystick is moving
                    joyRest=false;
                    trace("joyZUp");
                    
                    //activates if statement on "page actions"
                    moveZUp=true;

                    //figure out how to rewrite a function, this is sloppy
                    //function based on focused page
                    if (currentPage=="page0") {
                        moveHighlight0();
                    } else if (currentPage == "page1") {
                        moveHighlight1();
                    } else if (currentPage == "page2") {
                        moveHighlight2();
                    } else if (currentPage == "page3") {
                        moveHighlight3();
                    } else if (currentPage == "page4") {
                        moveHighlight4();
                    } else if (currentPage == "page5") {
                        moveHighlight5();
                    } else if (currentPage == "page6") {
                        moveHighlight6();
                    }
                }

            //right analoge range
            } else if (e.value > 550) {
                
                //Checks to see that joystick is centered
                if (joyRest==true) {
                    
                    //restrict receiving analog data to x-axis only
                    movingZ = true;
                    
                    //say that joystick is moving
                    joyRest=false;
                    trace("joyZDown");
                
                    //activates if statement on "page actions"
                    moveZDown=true;

                    //figure out how to rewrite a function, this is sloppy
                    //function based on focused page
                    if (currentPage=="page0") {
                        moveHighlight0();
                    } else if (currentPage == "page1") {
                        moveHighlight1();
                    } else if (currentPage == "page2") {
                        moveHighlight2();
                    } else if (currentPage == "page3") {
                        moveHighlight3();
                    } else if (currentPage == "page4") {
                        moveHighlight4();
                    } else if (currentPage == "page5") {
                        moveHighlight5();
                    } else if (currentPage == "page6") {
                        moveHighlight6();
                    }
                }
            
            //rest analog range
            } else if (e.value >= 470 && e.value <= 530) {
                
                //allow receiving analog data to all axis again
                movingZ = false;
                
                //joystick returned to center
                //allow another direction to be triggered
                joyRest=true;
                
                smoothZUp = false;
                smoothZDown = false;
                
                moveZUp = false;
                moveZDown = false;
                moveLeft=false;
                moveRight=false;
                moveUp=false;
                moveDown=false;
            }
        }
    }
}

//TESTING CODE BELOW THIS LINE
/**
//listen for key press
stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyPressed);

//check to see if key way UP, DOWN, or RIGHT
function KeyPressed(event:KeyboardEvent):void {
trace(event.keyCode);

if (event.keyCode==38) {
    trace("UP");
    moveUp=true;
    if (currentPage=="page0") {
        moveHighlight0();
    } else if (currentPage == "page1") {
        moveHighlight1();
    } else if (currentPage == "page2") {
        moveHighlight2();
    } else if (currentPage == "page3") {
        moveHighlight3();
    } else if (currentPage == "page4") {
        moveHighlight4();
    } else if (currentPage == "page5") {
        moveHighlight5();
    } else if (currentPage == "page6") {
        moveHighlight6();
    }

}
if (event.keyCode==40) {
trace("DOWN");
moveDown=true;
if (currentPage=="page0") {
moveHighlight0();
} else if (currentPage == "page1") {
moveHighlight1();
} else if (currentPage == "page2") {
moveHighlight2();
} else if (currentPage == "page3") {
moveHighlight3();
} else if (currentPage == "page4") {
moveHighlight4();
} else if (currentPage == "page5") {
moveHighlight5();
} else if (currentPage == "page6") {
moveHighlight6();
}

}
if (event.keyCode==39) {
trace("RIGHT");
moveRight=true;
if (currentPage=="page0") {
moveHighlight0();
} else if (currentPage == "page1") {
moveHighlight1();
} else if (currentPage == "page2") {
moveHighlight2();
} else if (currentPage == "page3") {
moveHighlight3();
} else if (currentPage == "page4") {
moveHighlight4();
} else if (currentPage == "page5") {
moveHighlight5();
} else if (currentPage == "page6") {
moveHighlight6();
}

}
if (event.keyCode==37) {
trace("LEFT");
moveLeft=true;
if (currentPage=="page0") {
moveHighlight0();
} else if (currentPage == "page1") {
moveHighlight1();
} else if (currentPage == "page2") {
moveHighlight2();
} else if (currentPage == "page3") {
moveHighlight3();
} else if (currentPage == "page4") {
moveHighlight4();
} else if (currentPage == "page5") {
moveHighlight5();
} else if (currentPage == "page6") {
moveHighlight6();
}

}
if (event.keyCode==51) {
trace("SELECT");
moveSelect=true;
if (currentPage=="page0") {
moveHighlight0();
} else if (currentPage == "page1") {
moveHighlight1();
} else if (currentPage == "page2") {
moveHighlight2();
} else if (currentPage == "page3") {
moveHighlight3();
} else if (currentPage == "page4") {
moveHighlight4();
} else if (currentPage == "page5") {
moveHighlight5();
} else if (currentPage == "page6") {
moveHighlight6();
}
}
if (event.keyCode==50) {
trace("CONFIRM");
moveConfirm=true;
if (currentPage=="page0") {
moveHighlight0();
} else if (currentPage == "page1") {
moveHighlight1();
} else if (currentPage == "page2") {
moveHighlight2();
} else if (currentPage == "page3") {
moveHighlight3();
} else if (currentPage == "page4") {
moveHighlight4();
} else if (currentPage == "page5") {
moveHighlight5();
} else if (currentPage == "page6") {
moveHighlight6();
}

}
if (event.keyCode==49) {
trace("BACK");
moveBack=true;
if (currentPage=="page0") {
moveHighlight0();
} else if (currentPage == "page1") {
moveHighlight1();
} else if (currentPage == "page2") {
moveHighlight2();
} else if (currentPage == "page3") {
moveHighlight3();
} else if (currentPage == "page4") {
moveHighlight4();
} else if (currentPage == "page5") {
moveHighlight5();
} else if (currentPage == "page6") {
moveHighlight6();
}
}
}

**/

```

Code on frame specific layer :

```auto

joyDir = "rest";
highlightedButton = btn3;
currentPage = "page0"

highlightedButton.gotoAndPlay("highlight");

//highlight a new button on navigation
function moveHighlight0(event:Event = null) {

    if (highlightedButton == btn0) {
        
        if (moveUp == true) {
            trace("moveUp");
            if (btn0.y <= 505) {
                btn0.y = 505
            } else {
                btn0.y = btn0.y -170;
            }
            //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;
            joyRest = false;
        }
        if (moveDown == true) {
            trace("moveDown");
            if (btn0.y >= 845) {
                btn0.y = 845
            } else {
                btn0.y = btn0.y +170;
            }
            joyRest = false;
            //highlightedButton.gotoAndPlay("rest");
            //highlightedButton = btn1;
            //targetPage = "page2";
            //highlightedButton.gotoAndPlay("highlight");
            moveDown = false;
        }
        if (moveLeft == true) {
            moveLeft = false;
            joyRest = false;
            trace("moveLeft");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn4;
            targetPage = "page1";
            highlightedButton.gotoAndPlay("highlight");
            
        }
        if (moveSelect == true) {
            trace("moveSelect");
            targetPage = "page1"
            highlightedButton.gotoAndPlay("rest");
            this.gotoAndStop(targetPage);
            //highlightedButton = btn0;
            //highlightedButton.gotoAndPlay("highlight");
            moveSelect = false;
        }
        if (moveConfirm == true) {
            trace("moveConfirm");
            highlightedButton.gotoAndPlay("rest");
            this.gotoAndStop("page1");
            //highlightedButton.gotoAndPlay("rest");
            //highlightedButton = btn1;
            //highlightedButton.gotoAndPlay("highlight");
            moveConfirm = false;
        }
        if (moveBack == true) {
            trace("moveBack");
            highlightedButton.gotoAndPlay("rest");
            //this.gotoAndStop("page0");
            //highlightedButton.gotoAndPlay("rest");
            //highlightedButton = btn1;
            //highlightedButton.gotoAndPlay("highlight");
            moveBack = false;
        }
    }
    
    if (highlightedButton == btn1) {
        if (moveUp == true) {
            trace("moveUp");
            //highlightedButton.gotoAndPlay("rest");
            //highlightedButton = btn0;
            //targetPage = "page2";
            //highlightedButton.gotoAndPlay("highlight");
            moveUp = false;
        }
        if (moveRight == true) {
            trace("moveRight");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn2;
            targetPage = "page1";
            highlightedButton.gotoAndPlay("highlight");
            moveRight = false;
        }
        if (moveDown == true) {
            trace("moveDown");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn2;
            targetPage = "page1";
            highlightedButton.gotoAndPlay("highlight");
            moveDown = false;
        }
        if (moveLeft == true) {
            moveLeft = false;
            joyRest = false;
            trace("moveLeft");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn0;
            targetPage = "page1";
            highlightedButton.gotoAndPlay("highlight");
        }
        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("page1");
            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;
        }
    }
    if (highlightedButton == btn2) {
        if (moveUp == true) {
            trace("moveUp");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn1;
            //targetPage = "page2";
            highlightedButton.gotoAndPlay("highlight");
            moveUp = false;
        }
        if (moveRight == true) {
            trace("moveRight");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn3;
            targetPage = "page1";
            highlightedButton.gotoAndPlay("highlight");
            moveRight = false;
        }
        if (moveDown == true) {
            trace("moveDown");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn3;
            targetPage = "page1";
            highlightedButton.gotoAndPlay("highlight");
            moveDown = false;
        }
        if (moveLeft == true) {
            moveLeft = false;
            joyRest = false;
            trace("moveLeft");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn0;
            targetPage = "page1";
            highlightedButton.gotoAndPlay("highlight");
        }
        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("page1");
            //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;
        }
    }
    if (highlightedButton == btn3) {
        if (moveUp == true) {
            trace("moveUp");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn2;
            //targetPage = "page2";
            highlightedButton.gotoAndPlay("highlight");
            moveUp = false;
        }
        if (moveRight == true) {
            trace("moveRight");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn4;
            targetPage = "page1";
            highlightedButton.gotoAndPlay("highlight");
            moveRight = false;
        }
        if (moveDown == true) {
            trace("moveDown");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn4;
            targetPage = "page1";
            highlightedButton.gotoAndPlay("highlight");
            moveDown = false;
        }
        if (moveLeft == true) {
            moveLeft = false;
            joyRest = false;
            trace("moveLeft");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn2;
            //targetPage = "page2";
            highlightedButton.gotoAndPlay("highlight");
        }
        if (moveSelect == true) {
            trace("moveSelect");
            targetPage = "page1"
            highlightedButton.gotoAndPlay("rest");
            this.gotoAndStop(targetPage);
            //highlightedButton = btn0;
            //highlightedButton.gotoAndPlay("highlight");
            moveSelect = false;
        }
        if (moveConfirm == true) {
            trace("moveConfirm");
            this.gotoAndStop("page1");
            //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;
        }
    }
    if (highlightedButton == btn4) {
        if (moveUp == true) {
            trace("moveUp");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn3;
            targetPage = "page1";
            highlightedButton.gotoAndPlay("highlight");
            moveUp = false;
        }
        if (moveRight == true) {
            trace("moveRight");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn0;
            targetPage = "page1";
            highlightedButton.gotoAndPlay("highlight");
            moveRight = false;
        }
        if (moveDown == true) {
            trace("moveDown");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn0;
            targetPage = "page1";
            highlightedButton.gotoAndPlay("highlight");
            moveDown = false;
        }
        if (moveLeft == true) {
            moveLeft = false;
            joyRest = false;
            trace("moveLeft");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn3;
            targetPage = "page1";
            highlightedButton.gotoAndPlay("highlight");

        }
        if (moveSelect == true) {
            trace("moveSelect");
            targetPage = "page1"
            highlightedButton.gotoAndPlay("rest");
            this.gotoAndStop(targetPage);
            //highlightedButton = btn0;
            //highlightedButton.gotoAndPlay("highlight");
            moveSelect = false;
        }
        if (moveConfirm == true) {
            trace("moveConfirm");
            this.gotoAndStop("page1");
            //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;
        }
    }
}

```

And then going to frame 2 specific code:

```auto

stop();

//INCLUDE AND SET for each page
joyDir = "rest";
highlightedButton = btn3;
currentPage = "page1"

highlightedButton.gotoAndPlay("highlight");

function moveHighlight1(event:Event = null) {

    if (highlightedButton == btn5) {
        if (moveUp == true) {
            trace("moveUp");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn8;
            targetPage = "page3";
            highlightedButton.gotoAndPlay("highlight");
            moveUp = false;
        }
        if (moveRight == true) {
            trace("moveRight");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn6;
            targetPage = "page2";
            highlightedButton.gotoAndPlay("highlight");
            moveRight = false;
        }
        if (moveDown == true) {
            trace("moveDown");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn6;
            targetPage = "page2";
            highlightedButton.gotoAndPlay("highlight");
            moveDown = false;
        }
        if (moveLeft == true) {
            trace("moveLeft");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn8;
            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;
        }
    }
    
    if (highlightedButton == btn6) {
        if (moveUp == true) {
            trace("moveUp");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn5;
            targetPage = "page2";
            highlightedButton.gotoAndPlay("highlight");
            moveUp = false;
        }
        if (moveRight == true) {
            trace("moveRight");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn7;
            targetPage = "page2";
            highlightedButton.gotoAndPlay("highlight");
            moveRight = false;
        }
        if (moveDown == true) {
            trace("moveDown");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn7;
            targetPage = "page2";
            highlightedButton.gotoAndPlay("highlight");
            moveDown = false;
        }
        if (moveLeft == true) {
            trace("moveLeft");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn5;
            targetPage = "page2";
            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("page3");
            //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;
        }
    }
    if (highlightedButton == btn7) {
        if (moveUp == true) {
            trace("moveUp");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn6;
            targetPage = "page2";
            highlightedButton.gotoAndPlay("highlight");
            moveUp = false;
        }
        if (moveRight == true) {
            trace("moveRight");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn8;
            targetPage = "page3";
            highlightedButton.gotoAndPlay("highlight");
            moveRight = false;
        }
        if (moveDown == true) {
            trace("moveDown");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn8;
            targetPage = "page3";
            highlightedButton.gotoAndPlay("highlight");
            moveDown = false;
        }
        if (moveLeft == true) {
            trace("moveLeft");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn6;
            targetPage = "page2";
            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("page3");
            //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;
        }
    }
    if (highlightedButton == btn8) {
        if (moveUp == true) {
            trace("moveUp");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn7;
            targetPage = "page2";
            highlightedButton.gotoAndPlay("highlight");
            moveUp = false;
        }
        if (moveRight == true) {
            trace("moveRight");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn5;
            targetPage = "page2";
            highlightedButton.gotoAndPlay("highlight");
            moveRight = false;
        }
        if (moveDown == true) {
            trace("moveDown");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn5;
            targetPage = "page2";
            highlightedButton.gotoAndPlay("highlight");
            moveDown = false;
        }
        if (moveLeft == true) {
            trace("moveLeft");
            highlightedButton.gotoAndPlay("rest");
            highlightedButton = btn7;
            targetPage = "page2";
            highlightedButton.gotoAndPlay("highlight");
            moveLeft = false;
        }
        if (moveSelect == true) {
            trace("moveSelect");
            targetPage = "page3"
            highlightedButton.gotoAndPlay("rest");
            this.gotoAndStop(targetPage);
            //highlightedButton = btn0;
            //highlightedButton.gotoAndPlay("highlight");
            moveSelect = false;
        }
        if (moveConfirm == true) {
            trace("moveConfirm");
            highlightedButton.gotoAndPlay("rest");
            this.gotoAndStop("page3");
            //highlightedButton.gotoAndPlay("rest");
            //highlightedButton = btn1;
            //highlightedButton.gotoAndPlay("highlight");
            moveConfirm = false;
        }
        if (moveBack == true) {
            trace("moveBack");
            highlightedButton.gotoAndPlay("rest");
            this.gotoAndStop("page0");
            //highlightedButton.gotoAndPlay("rest");
            //highlightedButton = btn1;
            //highlightedButton.gotoAndPlay("highlight");
            moveBack = false;
        }
    }
}

```
