I have a guy moving around a maze. Set up pretty well. However, I have one problem
TypeError: Error #1006: hitTestObject is not a function.
at mazegame_fla::MainTimeline/handleCollision()
Here is my code:
ActionScript Code:
import flash.display.MovieClip;
import flash.events.Event;
stop();
/* Click to Go to Scene and Play
Clicking on the specified symbol instance plays the movie from the specified scene and frame.
Instructions:
1. Replace "Scene 3" with the name of the scene you would like play.
2. Replace 1 with the frame number you would like the movie to play from in the specified scene.
*/
return_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_6);
function fl_ClickToGoToScene_6(event:MouseEvent):void
{
MovieClip(this.root).gotoAndPlay(1, "Scene 1");
}
stop();
var walls:Array = new Array(wall4_mc,wall5_mc,wall6_mc,wall7_mc,wall8_mc,wall9_mc,wall10_mc,wall11_mc,wall12_mc,wall13_mc,wall14_mc,wall15_mc,wall16_mc);
stage.addEventListener(KeyboardEvent.KEY_DOWN, pressKeyDown);
function pressKeyDown (e:KeyboardEvent):void{
if (e.keyCode == Keyboard.LEFT){
dude_mc.x -=5;
}
if (e.keyCode == Keyboard.RIGHT){
dude_mc.x +=5;
}
if (e.keyCode == Keyboard.UP){
dude_mc.y -=5;
}
if (e.keyCode == Keyboard.DOWN){
dude_mc.y +=5;
}
}
this.addEventListener(Event.ENTER_FRAME, handleCollision)
function handleCollision( e:Event ):void
{
if(dude_mc.hitTestObject(hit_mc))
{
gotoAndPlay("1","Scene 6");
}
else if(walls.hitTestObject(dude_mc))
{
gotoAndStop("1","Scene 5");
}
}