# Move a mc if \_ymouse is \< 50

**URL:** <https://forum.kirupa.com/t/move-a-mc-if--ymouse-is-50/11600>\
**Category:** flash\
**Created:** [January 19, 2003, 9:35pm UTC](https://forum.kirupa.com/t/move-a-mc-if--ymouse-is-50/11600 "2003-01-19T21:35:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![thorseye](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/thorseye/32/66_2.png) [@thorseye](https://forum.kirupa.com/u/thorseye)\
**Post date:** [January 19, 2003, 9:35pm UTC](https://forum.kirupa.com/t/move-a-mc-if--ymouse-is-50/11600/1 "2003-01-19T21:35:13Z")

</div>

Hellooo  
I want to do this: When the mouse is between two y-coordinates, let’s say 40 and 50, a movieclip is supposed to be moved. How should I do this? I can move the movieclip by clicking on a button but how do I do this one? And where should the code be put? I thought that this code would work if I put it in the first frame, but it’s not…

```auto
if (_root._ymouse < 55) {
			   newpos = 100;
			   }

```

Please help…

---

<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:** [January 19, 2003, 9:37pm UTC](https://forum.kirupa.com/t/move-a-mc-if--ymouse-is-50/11600/2 "2003-01-19T21:37:32Z")

</div>

Haha… Never mind… I put the code in an empty mc inside a onClipEvent(enterFrame) action and tadaa! =)

---

<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:** [January 19, 2003, 9:39pm UTC](https://forum.kirupa.com/t/move-a-mc-if--ymouse-is-50/11600/3 "2003-01-19T21:39:56Z")

</div>

you have to make a 2-frame-loop or put the actions on a movieclip within the onClipEvent(enterFrame) handlers!

2-frame-loop:  
put the actions in the first frame and make another keyframe in frame 2 and add the action:  
gotoAndPlay(1);  
on the second keyframe so it will go to the 1st frame, then the 2nd and then the first on again!

or

movieclip:  
put the actions on a movieclip like this:

onClipEvent(enterFrame) {  
if (\_root.\_ymouse \< 55) {  
newpos = 100;  
}  
}

onClipEvent( **enterFrame** )  
enterframe triggers the actions within the handlers every frame! [so if your fps is 20 the actions will be triggered 20 times per second]

🙂

---

<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:** [January 19, 2003, 9:44pm UTC](https://forum.kirupa.com/t/move-a-mc-if--ymouse-is-50/11600/4 "2003-01-19T21:44:05Z")

</div>

yupp… As I wrote before I did like you said… Thanks anyway for a quick answer!! =)
