In the function hitWall, hitTestObject is working when a player hits the wall. I have walls on the flash stage, named wall, wall2, wall3, wall4. Using that same concept, I placed other movieclips (trees) and named them: tree1, tree2, etc....etc...
I'm receiving an error message: Access of undefined property tree.
wall.addEventListener(Event.ENTER_FRAME, hitWall);
tree.addEventListener(Event.ENTER_FRAME, hitTree);
// function hitWall --------------------------------------------------------------
function hitWall(event:Event):void {
if (player_ary[me].hitTestObject(wall)) {
player_ary[me].y+=6;
} else if (player_ary[me].hitTestObject(wall2)) {
player_ary[me].y-=6;
} else if (player_ary[me].hitTestObject(wall3)) {
player_ary[me].x+=6;
} else if (player_ary[me].hitTestObject(wall4)) {
player_ary[me].x-=6;
}
}
// function hitWall --------------------------------------------------------------
function hitTree(event:Event):void {
if (player_ary[me].hitTestObject(tree)) {
player_ary[me].y+=6;
} else if (player_ary[me].hitTestObject(tree2)) {
player_ary[me].y-=6;
} else if (player_ary[me].hitTestObject(tree3)) {
player_ary[me].x+=6;
}
}