# \[AS2\] xmouse coordnates play MC.. halp!

**URL:** <https://forum.kirupa.com/t/as2-xmouse-coordnates-play-mc-halp/262705>\
**Category:** flash\
**Created:** [June 9, 2008, 11:04am UTC](https://forum.kirupa.com/t/as2-xmouse-coordnates-play-mc-halp/262705 "2008-06-09T11:04:37Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhf80](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@jhf80](https://forum.kirupa.com/u/jhf80)\
**Post date:** [June 9, 2008, 11:04am UTC](https://forum.kirupa.com/t/as2-xmouse-coordnates-play-mc-halp/262705/1 "2008-06-09T11:04:37Z")

</div>

hi… im trying to make a mc start playing by moving the mouse (\_xmouse) of to the right side… I need to make the mc paly without the use of a rollover button when the mouse passes over a the last 100 or so pixels to the right… i been trying to modify this scrip to do the job but it currently plays the mc with every little move of the mouse.

var mouseListener:Object = new Object();

mouseListener.onMouseMove = function() {  
if (root.\_xmouse, true) {  
mymovieclip.play(1);  
}  
else if (\_xmouse, false) {  
mymovieclip.gotoAndStop(1);  
}  
};

Mouse.addListener(mouseListener);

any ideas?

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [June 9, 2008, 11:24am UTC](https://forum.kirupa.com/t/as2-xmouse-coordnates-play-mc-halp/262705/2 "2008-06-09T11:24:31Z")

</div>

```auto
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
	if (_xmouse < 100) {
		mymovieclip.play();
	} else {
		mymovieclip.gotoAndStop(1);
	}
};

```

---

<div class="post-metadata">

**Author:** ![jhf80](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@jhf80](https://forum.kirupa.com/u/jhf80)\
**Post date:** [June 9, 2008, 11:40am UTC](https://forum.kirupa.com/t/as2-xmouse-coordnates-play-mc-halp/262705/3 "2008-06-09T11:40:56Z")

</div>

Great… that worked with a little ajusting 😛 thanks… any ideas how i can make it play once and stop? It ceeps playing over and over when i move the mouse with this code…

Again… thanks… this has been haunting me all wekend!

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [June 9, 2008, 1:15pm UTC](https://forum.kirupa.com/t/as2-xmouse-coordnates-play-mc-halp/262705/4 "2008-06-09T13:15:12Z")

</div>

You’ll need to set up a condition to check if the movie has been played, e.g.  
played = false;  
if (\_xmouse \< 100 && !played) {  
mymovieclip.play();  
played = true;  
}

---

<div class="post-metadata">

**Author:** ![jhf80](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@jhf80](https://forum.kirupa.com/u/jhf80)\
**Post date:** [June 9, 2008, 3:20pm UTC](https://forum.kirupa.com/t/as2-xmouse-coordnates-play-mc-halp/262705/5 "2008-06-09T15:20:32Z")

</div>

hmm… i cant seem to make that work. exactly where where in the script should the condition be palced?  
This is more advanced actionscripting compared to what im used to doing :S

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [June 9, 2008, 4:36pm UTC](https://forum.kirupa.com/t/as2-xmouse-coordnates-play-mc-halp/262705/6 "2008-06-09T16:36:17Z")

</div>

Add played = true; to the last frame in mymovieclip.  
Then change your code to this:

```auto
mymovieclip.stop();
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
	if (_xmouse < 100 && !mymovieclip.played) {
		mymovieclip.play();
	} else {
		mymovieclip.gotoAndStop(1);
	}
};
Mouse.addListener(mouseListener);

```

---

<div class="post-metadata">

**Author:** ![jhf80](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@jhf80](https://forum.kirupa.com/u/jhf80)\
**Post date:** [June 9, 2008, 7:06pm UTC](https://forum.kirupa.com/t/as2-xmouse-coordnates-play-mc-halp/262705/7 "2008-06-09T19:06:29Z")

</div>

thanks, im learning alot here… and with this im almost there… now i just need the movieclip to stop and freeze in the last frame, and not pop back to start at the next mouse movement… im guessing i need another variable but im in over my head now… if you have a solution for me i wold be extremly grateful…

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [June 9, 2008, 7:49pm UTC](https://forum.kirupa.com/t/as2-xmouse-coordnates-play-mc-halp/262705/8 "2008-06-09T19:49:45Z")

</div>

I assumed that you wanted it to continue looping. To get it to stop, just add stop(); to the last frame of the mc as well.

---

<div class="post-metadata">

**Author:** ![jhf80](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@jhf80](https://forum.kirupa.com/u/jhf80)\
**Post date:** [June 9, 2008, 7:57pm UTC](https://forum.kirupa.com/t/as2-xmouse-coordnates-play-mc-halp/262705/9 "2008-06-09T19:57:49Z")

</div>

well… heres the thing, my movieclip is a shhet of paper beeing flipped… i want it to stay flipped so the page underneath is shown. -so i dont want it to loop… i want it to play once and stay “open” -frosen at the last frame…

thanks for your ansvers and patirence 🙂

---

<div class="post-metadata">

**Author:** ![jhf80](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@jhf80](https://forum.kirupa.com/u/jhf80)\
**Post date:** [June 10, 2008, 10:54am UTC](https://forum.kirupa.com/t/as2-xmouse-coordnates-play-mc-halp/262705/10 "2008-06-10T10:54:20Z")

</div>

any advice? im still stuck :-/

---

<div class="post-metadata">

**Author:** ![jhf80](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@jhf80](https://forum.kirupa.com/u/jhf80)\
**Post date:** [June 10, 2008, 11:15am UTC](https://forum.kirupa.com/t/as2-xmouse-coordnates-play-mc-halp/262705/11 "2008-06-10T11:15:13Z")

</div>

i solved it :D:D you where right, just needed a stop at the right place… thank you so mutch 😃
