basically, there is a box on stage with an instance name of "box" whose class is called "BoxHitTest"... when i rollover the box, its supposed to trace out: "hitting"... but its not working.
the timeline doesnt contain any code.. the only code is inside the BoxHitTest class...
ActionScript Code:
package
{
import flash.display.*;
import flash.events.*;
public class BoxHitTest extends MovieClip
{
public function BoxHitTest()
{
addEventListener(Event.ENTER_FRAME, runEnterFrame);
}
function runEnterFrame(event:Event):void
{
if(this.hitTestPoint(mouseX, mouseY))
{
trace("hitting");
}
}
}
}
what's wrong with my code?
if i type the code on the main timeline below, then it works..
ActionScript Code:
stage.addEventListener(Event.ENTER_FRAME, runEnterFrame);
function runEnterFrame(event:Event):void
{
if(box.hitTestPoint(mouseX, mouseY))
{
trace("hitting");
}
}
so how should i use hitTestPoint inside a class to make it work properly?