This is a straight ripped from http://labs.bigspaceship.com/2008/10/16/as3-optimization-tip/

stage.addEventListener(Event.MOUSE_LEAVE, _onLeaveStage, false, 0, true);
// followed by:
private function _onLeaveStage($evt:Event):void
{
// disable site code
stage.addEventListener(MouseEvent.MOUSE_MOVE, _onReturnToStage, false, 0, true);
};
private function _onReturnToStage($evt:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, _onReturnToStage);
//re-enable site code
};

Advertisements