# Start MC with mouse position

**URL:** <https://forum.kirupa.com/t/start-mc-with-mouse-position/111379>\
**Category:** Uncategorized\
**Created:** [May 26, 2004, 1:06pm UTC](https://forum.kirupa.com/t/start-mc-with-mouse-position/111379 "2004-05-26T13:06:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhunki](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@mhunki](https://forum.kirupa.com/u/mhunki)\
**Post date:** [May 26, 2004, 1:06pm UTC](https://forum.kirupa.com/t/start-mc-with-mouse-position/111379/1 "2004-05-26T13:06:53Z")

</div>

I’m trying to make a movie clip play when the mouse is in a certain position on the screen without using invisible buttons, coding this myself so far I’ve got

\_root.top = 319  
\_root.bottom = 445  
yval = \_root.\_ymouse;  
if (\_root.\_ymouse \> \_root.top) {  
\_root.flowers.play();  
} else {  
\_root.flowers.stop();  
}

doesn’t seem to work right.

Any ideas?

---

<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 26, 2004, 7:47pm UTC](https://forum.kirupa.com/t/start-mc-with-mouse-position/111379/2 "2004-05-26T19:47:34Z")

</div>

Put the [font=courier new]if[/font] and [font=courier new]else[/font] statements within an [font=courier new]onMouseMove[/font] event handler?

```auto
var top = 319;
var bottom = 445;
flowers.onMouseMove = function() {
	if (_ymouse>top && _ymouse<bottom) {
		this.play();
	} else {
		this.stop();
	}
};

```

---

<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 27, 2004, 7:49am UTC](https://forum.kirupa.com/t/start-mc-with-mouse-position/111379/3 "2004-05-27T07:49:18Z")

</div>

I experimented after I’d posted and moved the code from the \_root level and applied it to the movie clip itself and addressed it using .this and it works alot better, I’m new to functions so I’ll try your code.

Thanks again

---

<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 28, 2004, 7:27am UTC](https://forum.kirupa.com/t/start-mc-with-mouse-position/111379/4 "2004-05-28T07:27:39Z")

</div>

Ok - You’re welcome. 🙂
