While working on an AIR / HTML project I needed to fire an event if the mouse left the window. This seemed fairly straight forward. Just add a mouseout to the html body.

view plain print about
1<body onmouseout="somefunction();" >

However, the onmouseout never fired. Adding the same onmouseout to a div also failed. So, I then tried to use jQuery's events to catch the mouseout

view plain print about
1$('#someDiv').mouseleave(function(){
2     //something here
3     });

Unfortunately, this had the same result; the event never fired.

I then started looking into AIR specific functions to see if there was something to accomplish this. To my non-surprise AIR has this handled.

view plain print about
1window.nativeWindow.stage.addEventListener('mouseLeave',function(e){
2     // some js here
3    });
4    
5    window.nativeWindow.stage.addEventListener('mouseOver',function(e){
6     // some js here
7    });

Till next time..

--Dave