# hitTestObject - any child

**URL:** <https://forum.kirupa.com/t/hittestobject-any-child/279404>\
**Category:** flash\
**Created:** [January 14, 2009, 12:39pm UTC](https://forum.kirupa.com/t/hittestobject-any-child/279404 "2009-01-14T12:39:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![trickeyd](https://avatars.discourse-cdn.com/v4/letter/t/f17d59/32.png) [@trickeyd](https://forum.kirupa.com/u/trickeyd)\
**Post date:** [January 14, 2009, 12:39pm UTC](https://forum.kirupa.com/t/hittestobject-any-child/279404/1 "2009-01-14T12:39:22Z")

</div>

Hi,

I was wondering if there is a way to run a hit test on any child within a MovieClip.

I am trying to create a maze MovieClip which contains a number of Wall children. I have an object that needs to know when it hits a wall.

This is the code within the object:

package  
{  
import flash.display.MovieClip;  
import flash.events.Event;

```
public class Mousey extends MovieClip
{
	private var Root:MovieClip;
	public function Mousey(m:MovieClip)
	{
		this.x = 200;
		this.y = 145;
		Root = m;
		Root.addChild(this);
		addEventListener(Event.ENTER_FRAME, go, false, 0, true);
	}
	public function go(Event)
	{
		this.y += 1;
		if(this.hitTestObject(Root.maze.child))
		{
			trace('Wall Hit')
		}
	}
}

```

}

If i select a child by name:

if(this.hitTestObject(Root.maze.wall))

it works fine, but I need it to work if any child is hit.

the error message is:

TypeError: Error #2007: Parameter hitTestObject must be non-null.  
at flash.display::DisplayObject/\_hitTest()  
at flash.display::DisplayObject/hitTestObject()  
at Mousey/go()

Thanks in advance for your help!
