# Ease my frustration please!

**URL:** <https://forum.kirupa.com/t/ease-my-frustration-please/8432>\
**Category:** Uncategorized\
**Created:** [November 21, 2002, 4:08am UTC](https://forum.kirupa.com/t/ease-my-frustration-please/8432 "2002-11-21T04:08:30Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![yorkshirepuddin](https://avatars.discourse-cdn.com/v4/letter/y/aeb1de/32.png) [@yorkshirepuddin](https://forum.kirupa.com/u/yorkshirepuddin)\
**Post date:** [November 21, 2002, 4:08am UTC](https://forum.kirupa.com/t/ease-my-frustration-please/8432/1 "2002-11-21T04:08:30Z")

</div>

Hi there,

The last few days I have been trying to figure out how to constrain a MC that follows the mouse on the Y axis with no luck.

While I have certainly come across many threads on the matter, on many boards, every method of doing it (including the mouse follow) is different and adding to my confusion.

Here’s the code I’m using, and by all means, if you know of something simplier, then let me know.

Okay, here it is:

onClipEvent (enterFrame) {  
mousey = \_root.\_Ymouse;  
if (mousey\<\_y) {  
followmouse = \_y-mousey;  
} else {  
followmouse = mousey-\_y;  
}  
moveSpeedx = followmouse/10;  
if (mousey\<\_y) {  
\_Y = \_Y-movespeedx;  
} else {  
\_Y = \_Y+movespeedx;  
}  
}

So, as I wanted this will follow my mouse. However, if the user was to go beyond the movie frame, I also lose the MC. I want to restrict it to a min of 20 and max of 230.

Can anyone help. I’m getting desparate here. Make me go to bed a happy girl.

Cheers. YP

---

<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:** [November 21, 2002, 4:12am UTC](https://forum.kirupa.com/t/ease-my-frustration-please/8432/2 "2002-11-21T04:12:30Z")

</div>

Think about it…

if (this.\_y\<20){  
this.\_y = 20;  
}

and

if (this.\_y\>230){  
this.\_y = 230;  
}

That keeps an object from going past a certain point.

---

<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:** [November 21, 2002, 4:31am UTC](https://forum.kirupa.com/t/ease-my-frustration-please/8432/3 "2002-11-21T04:31:56Z")

</div>

Thanks.

I’m fairly new to AS do you’ll have to forgive me. Where would this go in my AS?

Is there an easier way (i.e. shorter AS) to do this?

YP

---

<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:** [November 21, 2002, 4:34am UTC](https://forum.kirupa.com/t/ease-my-frustration-please/8432/4 "2002-11-21T04:34:51Z")

</div>

The code goes in your onEnterFrame section, you will need to modify it to fit the needs of your movie, I can’t see exactly how everything works so that is up to you.

That is as short as you are going to get it.

---

<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:** [November 21, 2002, 4:49am UTC](https://forum.kirupa.com/t/ease-my-frustration-please/8432/5 "2002-11-21T04:49:09Z")

</div>

THANKS A BUNCH!!! It works. I had to do another clipevent until I figure out how to incorporate both scripts but I got it from here.

Thanks.

---

<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:** [November 21, 2002, 4:49am UTC](https://forum.kirupa.com/t/ease-my-frustration-please/8432/6 "2002-11-21T04:49:43Z")

</div>

No problem 🙂

---

<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:** [November 21, 2002, 5:14am UTC](https://forum.kirupa.com/t/ease-my-frustration-please/8432/7 "2002-11-21T05:14:57Z")

</div>

Lost, you seem to be the king of simple-yet-advanced Action Script.

---

<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:** [November 21, 2002, 5:16am UTC](https://forum.kirupa.com/t/ease-my-frustration-please/8432/8 "2002-11-21T05:16:54Z")

</div>

LOL, I am not the king of any kind of AS, but I am very good at simple AS…lol.

---

<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:** [November 21, 2002, 7:58am UTC](https://forum.kirupa.com/t/ease-my-frustration-please/8432/9 "2002-11-21T07:58:19Z")

</div>

lost is too modest. He’s ‘da man’, don’t let him fool you.

---

<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:** [November 21, 2002, 8:07am UTC](https://forum.kirupa.com/t/ease-my-frustration-please/8432/10 "2002-11-21T08:07:36Z")

</div>

Yes, I am ‘da man’ of simple AS 😛

---

<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:** [November 21, 2002, 2:25pm UTC](https://forum.kirupa.com/t/ease-my-frustration-please/8432/11 "2002-11-21T14:25:19Z")

</div>

You never fool me lost!

I believe that in my post #3 I have said that. Or something like: “Yeah, lib rox!”

I´m way ahead of you. 😛

=)

---

<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:** [November 21, 2002, 6:39pm UTC](https://forum.kirupa.com/t/ease-my-frustration-please/8432/12 "2002-11-21T18:39:07Z")

</div>

Thanks guys 🙂
