# Mouse follow in flash MX

**URL:** <https://forum.kirupa.com/t/mouse-follow-in-flash-mx/1886>\
**Category:** Uncategorized\
**Created:** [May 4, 2002, 6:49am UTC](https://forum.kirupa.com/t/mouse-follow-in-flash-mx/1886 "2002-05-04T06:49:53Z")\
**Posts on this page:** 8\
**Page:** 1

<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:** [May 4, 2002, 6:49am UTC](https://forum.kirupa.com/t/mouse-follow-in-flash-mx/1886/1 "2002-05-04T06:49:53Z")

</div>

Hi, I just got my copy of Flash MX…have a few simple questions.\r\r\rWhat actionscript commands involves a movie following the mouse in vertical directions? Is this done by calculating/constraining the rectangle area?\r\rexample:\r\r[www.hugeinc.com/2001/huge\_1000.html](http://www.hugeinc.com/2001/huge_1000.html)\r\r----------------------\r\rIf i would like to have a movie slide from point A to point B according to the movement of the mouse position, what actionscript will it involve?\r\r\r-----------------------\r\ralso, what is the use of xmouse and xscale? \r\r\r\rThanks guys.\r\r\r\r\r\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:** [May 4, 2002, 9:14am UTC](https://forum.kirupa.com/t/mouse-follow-in-flash-mx/1886/2 "2002-05-04T09:14:16Z")

</div>

Well… \_xmouse is a global property which requests the location of the mouse’s x possition on the player.\r\r\_xscale is a property which is similar to \_width. It discribes a property of scale to the width of an object.\r\rAs for your request… it’s the same as Flash 5.0 unless they’ve got a new way of doing it. Either way, the 5.0 version of the script will still work.\r\rthis code is placed on the movie clip that is to move\r\ronClipEvent(enterFrame){\rdiff=\_ymouse-\_y;\rthis.\_y+=diff/50;\r}\r\rThe division by 50 is arbatrary. If you want it to move more slowly towards the mouse up the amount that you’re dividing it into. If you want the object to follow exactly where the mouse is, take out the /50 entirely.\r\r(PS I’m doing this from my head so if that doesn’t seem to work, change line 2 to\rdiff=\_y-\_ymouse;\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:** [May 4, 2002, 2:17pm UTC](https://forum.kirupa.com/t/mouse-follow-in-flash-mx/1886/3 "2002-05-04T14:17:51Z")

</div>

Hey Upu, the problem with your script is that you have to put \_root.\_ymouse, or \_parent.\_ymouse.\r\rIf you want to do that with MX, you can do it with callbacks functions. Put your clip on the scene, give it the instance name \*\* cli\*\* and then in the \*\* FIRST FRAME OF YOUR MOVIE\*\* (not on the clip !) enter :

```auto
 cli.onEnterFrame = function () { \r\r&nbsp &nbsp &nbsp &nbsp diff=_root._ymouse-this._y;\r\r&nbsp &nbsp &nbsp &nbsp this._y+=diff/15;\r\r}

```

pom 0]

---

<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:** [May 4, 2002, 2:27pm UTC](https://forum.kirupa.com/t/mouse-follow-in-flash-mx/1886/4 "2002-05-04T14:27:46Z")

</div>

And after deep thinking, \_width and \_xscale are reated but not the same thing. For instance, if the movie is originally 75 pixels wide, you’ll have \_width=75 and \_xscale=100.\rNow if you do \_xscale\*=2, you’ll have \_width=150 and \_xscale=200.\rNot the same thing, but similar.\r\rpom 0]

---

<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:** [May 4, 2002, 2:38pm UTC](https://forum.kirupa.com/t/mouse-follow-in-flash-mx/1886/5 "2002-05-04T14:38:54Z")

</div>

Last but not least, this thing on that site was done with masks. If you’re using F5, see my _cough_ amazing _cough_ tutorial on this site, and if you’re on MX, there’s a post somewhere about that.\r\rpom 0]

---

<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:** [May 5, 2002, 3:58am UTC](https://forum.kirupa.com/t/mouse-follow-in-flash-mx/1886/6 "2002-05-05T03:58:24Z")

</div>

You know what, you guys are amazing. thanks for your help.\r\rWhat is your advice to someone like me who started using flash one month ago…and would like to get serious with actionscipting? Do i need to get a book, learn the basics go form there Or is it like HTML, where you can kinda skip the basics and do a trial by error thingy? \r\rOne month has taught me alot - do visit - [www.jonwee.com](http://www.jonwee.com)\r\rcheers!\r\rP/s: ilyaslamasses : i did learn masking through your _cough_ masking thing. got it in an hour, now i’m trying to take it to the next level by controlling the masked area with the movement of the mouse like hugeinc’s.\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:** [May 5, 2002, 9:32am UTC](https://forum.kirupa.com/t/mouse-follow-in-flash-mx/1886/7 "2002-05-05T09:32:17Z")

</div>

One month, hue ? I’m impressed. The design of your site is really great. It’s just too bad that there’s not more Flash in it, but I’m sure there will in no time.\r\rAbout that mask control, asI said, if you’re working with MX, nothing simpler, and if you’re on F5, and if you’ve understood that _cough_ truely amazing _cough_ tutorial of mine, there shouldn’t be any problem (as a matter of fact, that’s the reason why I made that effect in the first place 😃 )\r\rpom 0]

---

<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:** [May 5, 2002, 5:25pm UTC](https://forum.kirupa.com/t/mouse-follow-in-flash-mx/1886/8 "2002-05-05T17:25:56Z")

</div>

yeah, its been a month since my company shut down and for the first time in years, i have the opportunity to play with flash as i always wanted to.\r\ractually, i did a basic html site as most of my clients, the market sector i am in - are kinda technically backwards. I deal with clients who are willing to pay good money for a site but are on a 56k modem and a 15 inch monitor. \r\rwhen i brush up on the flash skills, then perhaps ill make a flash version of the site. \r\rbut actionscripts…actionscipts…Need to master it…arrggh!!!\r\r\r\r
