Monday, December 15, 2008

Mouse enter and leave a movieclip using the Point object

Detect mouse entering and exiting a movieclip. Using this will allow rollover/out fuctionality without messing up mouse interaction of nested clips.


slideshow_mc.arrowsHotspots_mc.addEventListener(Event.ENTER_FRAME, watchForMouseEntry);
var point1:Point=new Point(0,0);
var mouseAlreadyInside:Boolean=false;
function watchForMouseEntry(e:Event):void {
point1.x=mouseX;
point1.y=mouseY;
var hs:Object=e.target;

if (hs.hitTestPoint(point1.x,point1.y,true)) {
if (mouseAlreadyInside==false) {
mouseAlreadyInside=true;
showControls()
}
} else {
if (mouseAlreadyInside==true) {
mouseAlreadyInside=false;
hideControls()
}
}
}

No comments: