type error 1010 help
This is my code thus far and i cannot figure out whey i am getting an error of
"TypeError: Error #1010: A term is undefined and has no properties.
at maze_fla::MainTimeline/frame1()"
var moveRight:Boolean=false;
var moveLeft:Boolean=false;
var moveUp:Boolean=false;
var moveDown:Boolean=false;
var colRight:Boolean=false;
var colLeft:Boolean=false;
var colUp:Boolean=false;
var colDown:Boolean=false;
var speed:Number=5;
//Stop flash from advancing to the next frame.
stop();
//Add an EventListener to the button
startPanel.startBTN.addEventListener(MouseEvent.CLICK, onStart);
//The game is frozen until this function is called
//when the user hits the start button.
function onStart(obj:MouseEvent):void {
//Remove the event listener for the button
startPanel.startBTN.removeEventListener(MouseEvent.CLICK, onStart);
//Remove the button from the screen
this.removeChild(startPanel);
//Start looping the game!
stage.addEventListener(Event.ENTER_FRAME, onLoop);
}
stage.addEventListener(Event.ENTER_FRAME, onLoop);
function onLoop(evt:Event):void {
//test for collision
onCollision();
//move the character
onMove();
}
function onCollision() {
if (maze.hitTestPoint(char.x+char.width/2,char.y,true)) {
moveRight=false;
}
//detect left side
if (maze.hitTestPoint(char.x-char.width/2,char.y,true)) {
moveLeft=false;
}
//detect upper ide
if (maze.hitTestPoint(char.x,char.y-char.height/2,true)) {
moveUp=false;
}
//detect left side
if (maze.hitTestPoint(char.x,char.y+char.height/2,true)) {
moveDown=false;
}
}
function onMove() {
if (moveRight==true) {
char.x+=speed;
}
if (moveLeft==true) {
char.x-=speed;
}
if (moveUp==true) {
char.y-=speed;
}
if (moveDown==true) {
char.y+=speed;
}
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPressed);
function onKeyPressed(evt:KeyboardEvent):void {
//trace("key is down");
switch (evt.keyCode) {
case Keyboard.RIGHT :
//trace("right arrow");
moveRight=true;
break;
case Keyboard.LEFT :
//trace("left arrow");
moveLeft=true;
break;
case Keyboard.UP :
//trace("up arrow");
moveUp=true;
break;
case Keyboard.DOWN :
///trace("down arrow");
moveDown=true;
break;
}
}
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyReleased);
function onKeyReleased(evt:KeyboardEvent):void {
//trace("key is up");
switch (evt.keyCode) {
case Keyboard.RIGHT :
//trace("right arrow up");
moveRight=false;
break;
case Keyboard.LEFT :
//trace("left arrow up");
moveLeft=false;
break;
case Keyboard.UP :
//trace("up arrow up");
moveUp=false;
break;
case Keyboard.DOWN :
//trace("down arrow up");
moveDown=false;
break;
}
}