Tip of the Day: Detecting When the Mouse Leaves the Movie

i tried this code, but nothing happened, any help


var cursor:Sprite = new Sprite();

function Test() {
    cursor.graphics.beginFill(0xFF9900);
    cursor.graphics.drawRect(0, 0, 25, 25);
    addChild(cursor);

    stage.addEventListener(Event.MOUSE_LEAVE, cursorHide);
    stage.addEventListener(MouseEvent.MOUSE_MOVE, cursorFollow);
    Mouse.hide();
}
function cursorHide(evt:Event):void {
    cursor.visible = false;
}
function cursorFollow(evt:MouseEvent):void {
    if (!cursor.visible) {
        cursor.visible = true;
    }
    cursor.x = stage.mouseX;
    cursor.y = stage.mouseY;
    evt.updateAfterEvent();
}