# I only want \_xmouse position only when over movie clip

**URL:** <https://forum.kirupa.com/t/i-only-want--xmouse-position-only-when-over-movie-clip/545>\
**Category:** flash\
**Created:** [July 22, 2002, 7:58am UTC](https://forum.kirupa.com/t/i-only-want--xmouse-position-only-when-over-movie-clip/545 "2002-07-22T07:58:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![3dron](https://avatars.discourse-cdn.com/v4/letter/3/2acd7d/32.png) [@3dron](https://forum.kirupa.com/u/3dron)\
**Post date:** [July 22, 2002, 7:58am UTC](https://forum.kirupa.com/t/i-only-want--xmouse-position-only-when-over-movie-clip/545/1 "2002-07-22T07:58:14Z")

</div>

onClipEvent (mouseMove) {  
x\_pos = \_xmouse;  
if (x\_pos\>x\_old) {  
\_root.var\_mov = 1;  
} else {  
\_root.var\_mov = -1;  
}  
x\_old = x\_pos;  
}

This works great for my needs. But I want it to only run when mouse is over the movieclip that contains the above script.

I understood by putting the script into this movie clip that it would work this way, but the variables are updated whether I am over the movieclip or elsewhere.

I’ve tried on(rollover) as well.

Can I get the \_mouse location of only this clip with something like this: \_ClipName.\_xmouse ?

Please help.

Ron R.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2002, 8:15am UTC](https://forum.kirupa.com/t/i-only-want--xmouse-position-only-when-over-movie-clip/545/2 "2002-07-22T08:15:07Z")

</div>

Dynamic event handlers are so cool !

```auto
this.onRollOver = function ()
{ 
    this.onMouseMove = function ()
    {
        x_pos = _xmouse; 
        if (x_pos>x_old)
        { 
            _root.var_mov = 1; 
        } else
        { 
            _root.var_mov = -1; 
        } 
        x_old = x_pos; 
    }
}
this.onRollOut = function ()
{
    this.onMouseMove = null;
}

```

Nice, hue ? =)

pom :asian:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2002, 8:23am UTC](https://forum.kirupa.com/t/i-only-want--xmouse-position-only-when-over-movie-clip/545/3 "2002-07-22T08:23:51Z")

</div>

By the way, this code can be shortened… Yours:

```auto
onClipEvent (mouseMove) { 
    _root.var_mov = (_xmouse>x_old)?1:-1 ;
    x_old = _xmouse; 
}

```

And mine:

```auto
this.onRollOver = function ()
{ 
    this.onMouseMove = function ()
    {
        _root.var_mov = (x_pos>x_old)?1:-1;
        x_old = _xmouse; 
    }
}
this.onRollOut = function ()
{
    this.onMouseMove = null;
}

```

x?y:z; means if x is true then y else do z. Watch for an article about AS for further information.

pom :asian:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2002, 5:16pm UTC](https://forum.kirupa.com/t/i-only-want--xmouse-position-only-when-over-movie-clip/545/4 "2002-07-22T17:16:32Z")

</div>

This one works great:

onClipEvent (mouseMove) {  
\_root.var\_mov = (\_xmouse\>x\_old)?1:-1 ;  
x\_old = \_xmouse;  
}

But neither works only when I am over their movie clip. THey both are active even when I am out side of movie clip.

How can I get the script to only be called when I am rolled over the clip?

RR

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 22, 2002, 5:36pm UTC](https://forum.kirupa.com/t/i-only-want--xmouse-position-only-when-over-movie-clip/545/5 "2002-07-22T17:36:05Z")

</div>

How can I implement this type of command in the short script form   
\_root.pano\_mov += 1;

Also, when I debugged the top code pano\_mov never changed beyond 1 or -1. Why did it not grow 1,2,3,2,1,0,-1-2,etc

I tried

```
var_mov = (_xmouse&gt;x_old)?+= 1:+= -1 ;

```

But it no like!!!

RR
