# Detect when mouse leaves movie

**URL:** https://forum.kirupa.com/t/detect-when-mouse-leaves-movie/183908
**Category:** flash
**Created:** [March 31, 2006, 3:00am UTC](https://forum.kirupa.com/t/detect-when-mouse-leaves-movie/183908 "2006-03-31T03:00:08Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![ginsengdesign](https://avatars.discourse-cdn.com/v4/letter/g/278dde/32.png) [@ginsengdesign](https://forum.kirupa.com/u/ginsengdesign)
#### Post date: [March 31, 2006, 3:00am UTC](https://forum.kirupa.com/t/detect-when-mouse-leaves-movie/183908/1 "2006-03-31T03:00:08Z")

</div>

Hi. I’m trying to have a function execute when the mouse leaves the entire stage. Unfortunately, if the mouse leaves too soon i need the animation thats going to finish before the new function executes. Kind of like a rollover/rolloff but for the entire movie.

I’ve tried a couple things but nothing works perfectly. You can see in my code below where I tried a few things with \_xmouse etc. I’m also not sure if i’m using the variables correctly. HELP!

```auto
var pos = "in";

import mx.transitions.Tween;
import mx.transitions.easing.*;
bigButton.onRollOver = function (){
    if (pos == "in"){
        pos = "moving";
        //Animation In using tween classes
            FadeDetails.onMotionFinished = function() {
                pos = "out";
            };
    };
    };
};
/*var xval = _root._xmouse;
var yval = _root._ymouse;
this.onEnterFrame = function() {
    if ( xval > 0 && xval < 460 && yval < 236 && yval > 0 ) {
    } else {
    //if (xval < 0 || xval > 602 || yval > 236 || yval < 0) {
        Close();
    };
};*/
bigButton.onRollOut = function (){
    Close();
};
function Close(){
    if (pos == "out") {
    pos = "moving";
            //Animation Out using tween classes
        MoveTextY2.onMotionFinished = function() {
            pos = "in";
        };
    };
    };
};

```
