No listeners involved. The thing is, I can use MOUSE_OVER and MOUSE_OUT listeners, but if you drag a mouse over a MovieClip quickly enough, one of these listeners may not be activated. I've tried it several times.
I have never had a problem with mouseOver and mouseOut.
But you can use hitTestPoint:
function detectMouseOver(d:DisplayObject):Boolean
{
var mousePoint:Point = d.localToGlobal(new Point(d.mouseX,d.mouseY));
return d.hitTestPoint(mousePoint.x,mousePoint.y,true);
}
You could also use stage.mouseX and stage.mouseY (and not localToGlobal), if you're certain that that property is available and set from where you're calling.
I haven't tested the code but I think it should work.
(edit)
But if you want to be absolutely sure that the mouse went over an object - even if you go so fast as to completely skip over it, you would have to check for points between mouse points of two frames.
That would make it, for instance:
d.addEventListener(Event.ENTER_FRAME, checkMouseOver);
var lastPoint:Point;
const MAX_DIST:Number = 10;
function checkMouseOver(e:Event):void
{
var isOver:Boolean = false;
var d:DisplayObject = e.currentTarget as DisplayObject;
var thisPoint:Point = d.localToGlobal(new Point(d.mouseX,d.mouseY))
if (lastPoint)
while (Point.distance(thisPoint,lastPoint) > MAX_DIST)
{
var diff:Point = thisPoint.subtract(lastPoint);
diff.normalize(MAX_DIST);
lastPoint = lastPoint.add(diff);
if (d.hitTestPoint(lastPoint.x,lastPoint.y,true))
{
isOver = true;
break;
}
}
if (d.hitTestPoint(thisPoint.x,thisPoint.y,true))
isOver = true;
lastPoint = thisPoint;
//do whatever you want with isOver here
}
You could remember if last state was over and dispatch a custom event when isOver != wasOver. If you do that inside the while loop you get a highly accurate mouse over detection.
But I bet that hitTestPoint with shapeFlag = true is fairly CPU heavy, especially if used a lot in one frame. So in this case you may want to set this MAX_DIST as high as you can.