Hard-To-Find Code

Just setting this up to store some code snippets i've needed that have been hard to find or build. In the process, hopefully, this will also be helpfull to others.

AS2 - Check whether the mouse had left the flash stage
(original web place)
==========================================================================

var mouse_dx:Number=_xmouse;
var mouse_dy:Number=_ymouse;
var mouseSpeed:Number=1;


function checkPosition(Void):Void {
if(_xmouse(Stage.width-mouseSpeed) || _ymouse(Stage.height-mouseSpeed)) {
in_mc._visible=false;
out_mc._visible=true;
trace("out");
} else {
in_mc._visible=true;
out_mc._visible=false;
trace("in");
}
}
checkPosition(Void);

var mouseListener:Object = new Object();
mouseListener.onMouseMove = function():Void {
mouse_dx = Math.abs(mouse_dx-_xmouse);
mouse_dy = Math.abs(mouse_dy-_ymouse);

mouseSpeed = mouse_dx > mouse_dy ? mouse_dx : mouse_dy;
mouseSpeed +=1;

checkPosition(Void);

mouse_dx=_xmouse;
mouse_dy=_ymouse;
}
Mouse.addListener(mouseListener);

==============================================================================