# Mouse X Y position help please

**URL:** <https://forum.kirupa.com/t/mouse-x-y-position-help-please/17318>\
**Category:** flash\
**Created:** [April 3, 2003, 7:35pm UTC](https://forum.kirupa.com/t/mouse-x-y-position-help-please/17318 "2003-04-03T19:35:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kel\_420](https://avatars.discourse-cdn.com/v4/letter/k/5e9695/32.png) [@Kel\_420](https://forum.kirupa.com/u/Kel_420)\
**Post date:** [April 3, 2003, 7:35pm UTC](https://forum.kirupa.com/t/mouse-x-y-position-help-please/17318/1 "2003-04-03T19:35:20Z")

</div>

Ok I have been randomly entering numbers so that when you move the mouse left the images move right and so on…

This is the code I’m using [I think I got it from FK originally a while back??].

```php

onClipEvent (mouseMove) {
    xmousepos1 = _xmouse;
    ymousepos1 = _ymouse;
    if (xmousepos1>xmousepos2 && ymousepos1>-98 && ymousepos1<-33) {
        _root.scrollclip.nextFrame();
    }
    if (xmousepos1-98 && ymousepos1<-33) {
        _root.scrollclip.prevFrame();
    }
    if (ymousepos1<-98 || ymousepos1>-33) {
        play ();
    }
    xmousepos2 = _xmouse;
    ymousepos2 = _ymouse;
}

```

As you can see from my [FLA](http://www.bluprint.com/downloads/senna01.zip) it’s not quite working the way it should. Is there a cleaner way of doing this?  
If so could someone kindly point me in the right direction before I beat myself to death with my mouse. ☹

[FLA Download](http://www.bluprint.com/downloads/senna01.zip)

Thanx in advance.

---

<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:** [April 3, 2003, 7:57pm UTC](https://forum.kirupa.com/t/mouse-x-y-position-help-please/17318/2 "2003-04-03T19:57:56Z")

</div>

try something like this instead. It will end up working better than what you are doing now…

edit++++

forgot the link:

[http://www.kirupa.com/developer/mx/infinite.htm](http://www.kirupa.com/developer/mx/infinite.htm)

---

<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:** [April 3, 2003, 8:00pm UTC](https://forum.kirupa.com/t/mouse-x-y-position-help-please/17318/3 "2003-04-03T20:00:08Z")

</div>

Thanx for that.

I did do a search but didn’t come across that tut.

Thanx again bro 😃

---

<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:** [April 3, 2003, 8:02pm UTC](https://forum.kirupa.com/t/mouse-x-y-position-help-please/17318/4 "2003-04-03T20:02:22Z")

</div>

no problem. Hope you get it sorted out. If you need anything else just post. 🙂

---

<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:** [April 3, 2003, 8:03pm UTC](https://forum.kirupa.com/t/mouse-x-y-position-help-please/17318/5 "2003-04-03T20:03:47Z")

</div>

Will do man 🙂 Cheers

---

<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:** [April 3, 2003, 9:36pm UTC](https://forum.kirupa.com/t/mouse-x-y-position-help-please/17318/6 "2003-04-03T21:36:59Z")

</div>

Hey, just another quick question. 🙂

Using the code from [this tut](http://www.kirupa.com/developer/mx/infinite.htm) how would I make the scroller move in the opposite direction to the mouse?

```php
onClipEvent (load)
{
   xcenter=285;
   speed=1/20;
}
onClipEvent (enterFrame)
{
   var distance=_root._xmouse-xcenter;
   _x+=(distance*speed);
   if (_x > 0) _x=-540;
   if (_x < -550) _x=0;
}

```

Again, thanx in advance

---

<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:** [April 3, 2003, 9:41pm UTC](https://forum.kirupa.com/t/mouse-x-y-position-help-please/17318/7 "2003-04-03T21:41:07Z")

</div>

i havent read the tutorial, but try

```auto
_x -= (distance*speed);

```

instead of

```auto
_x+=(distance*speed);

```

---

<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:** [April 3, 2003, 9:44pm UTC](https://forum.kirupa.com/t/mouse-x-y-position-help-please/17318/8 "2003-04-03T21:44:09Z")

</div>

I can’t believe I missed that lol.  
Thanx man that did the job!!  
Nice 1
