stage.addEventListener( Event.MOUSE_LEAVE, mouseLeaveListener );
Here is some code that detects enter/exit. Just paste into main timeline, compile, then view embedded in an html page:
//draw a box for demonstration purposes
var c:Sprite = new Sprite();
c.graphics.beginFill(0xFF);
c.graphics.drawRect(0, 0, 200, 200);
addChild(c);
//NOTE this only works embedded in a web page
//detect mouse leaving flash and rolling over web page
stage.addEventListener(Event.MOUSE_LEAVE, cursorHide);
//there is no mouse exit so you need to use this
stage.addEventListener(MouseEvent.MOUSE_MOVE, cursorFollow);
function cursorHide(evt:Event):void {
c.alpha=.2
}
function cursorFollow(evt:MouseEvent):void {
c.alpha=1
evt.updateAfterEvent();
}
No comments:
Post a Comment