Thursday, May 31, 2012

[Action Script] (hitTest) cannot convert to flash.display.DisplayObject May,2012

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

public class guard extends MovieClip
{
public function guard()
{

this.addEventListener(Event.ENTER_FRAME,ouch);

function ouch(e:Event):void
{
if (MovieClip(parent).player.hitTestObject(this))
{
trace("ouch!");

}
}
}

}
}

when ever i run the codes, i will have this error:
TypeError: Error #1034: Type Coercion failed: cannot convert global@2d54f29 to flash.display.DisplayObject.
at Function/guard/$construct/ouch()[C:\Users\User\Desktop\test\guard.as:19

i cant find wheres the error coming from. help please!
(hitTest) cannot convert to flash.display.DisplayObject

Related Post



0 comments: