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

**URL:** <https://forum.kirupa.com/t/tip-of-the-day-detecting-when-the-mouse-leaves-the-movie/281801>\
**Category:** flash\
**Created:** [February 13, 2009, 10:41am UTC](https://forum.kirupa.com/t/tip-of-the-day-detecting-when-the-mouse-leaves-the-movie/281801 "2009-02-13T10:41:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![smallDot](https://avatars.discourse-cdn.com/v4/letter/s/a8b319/32.png) [@smallDot](https://forum.kirupa.com/u/smallDot)\
**Post date:** [February 13, 2009, 10:41am UTC](https://forum.kirupa.com/t/tip-of-the-day-detecting-when-the-mouse-leaves-the-movie/281801/1 "2009-02-13T10:41:57Z")

</div>

i tried this code, but nothing happened, any help

```auto

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();
}

```
