# hitTestPoint AS3

**URL:** <https://forum.kirupa.com/t/hittestpoint-as3/310442>\
**Category:** programming\
**Created:** [June 10, 2010, 7:37am UTC](https://forum.kirupa.com/t/hittestpoint-as3/310442 "2010-06-10T07:37:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![habes](https://avatars.discourse-cdn.com/v4/letter/h/e5b9ba/32.png) [@habes](https://forum.kirupa.com/u/habes)\
**Post date:** [June 10, 2010, 7:37am UTC](https://forum.kirupa.com/t/hittestpoint-as3/310442/1 "2010-06-10T07:37:13Z")

</div>

Im trying to use hitTestPoint to detect if a enemy has hit a wall. I have the code working for the player, which is located on the main stage (the player doesn’t move, the map scrolls). The map, with the enemies is located in a MC - mainmap. mainmap contains walls MC and an instance of enemy. I can’t seem to get the code to work for the enemy’s hitTest. Any ideas to where Im going wrong? Maybe this is the wrong method to use.

SWF:  
[http://www.swfcabin.com/open/1276151501](http://www.swfcabin.com/open/1276151501)

Code on the enemy:

```php
for (var i:int = 0; i < thisParent.walls.numChildren; i++) {
		var obj:MovieClip=thisParent.walls.getChildAt(i) as MovieClip;
		if (obj.hitTestPoint(this.x+35,this.y)) {
			this.x-=enemySpeed;
		}
		if (obj.hitTestPoint(this.x-35,this.y)) {
			this.x+=enemySpeed;
		}
		if (obj.hitTestPoint(this.x,this.y+40)) {
			this.y-=enemySpeed; }
		if (obj.hitTestPoint(this.x,this.y-40)) {
			this.y+=enemySpeed;
		}
}

```

Any help would be great!
