Skip to main content
Participant
October 31, 2011
Question

type error 1010 help

  • October 31, 2011
  • 1 reply
  • 606 views

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;

          }

}

This topic has been closed for replies.

1 reply

Peter Celuch
Legend
October 31, 2011

My guess is that you don't have a MovieClip named startPanel on the stage on frame1.

Peter Celuch
Legend
October 31, 2011

It would be great if you gave us more information. Try testing the app not by Ctrl+Enter, but Shift+Ctrl+Enter. This way you will get better error message we can work with.

When the error occures, Flash Professional will go to Debug mode. Don't worry - just click big red X button on the left side of the screen and copy the error message from the Ouput panel.