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!