# Using \_xmouse to display a certain frame of a MC

**URL:** <https://forum.kirupa.com/t/using--xmouse-to-display-a-certain-frame-of-a-mc/63603>\
**Category:** Uncategorized\
**Created:** [September 8, 2004, 10:47am UTC](https://forum.kirupa.com/t/using--xmouse-to-display-a-certain-frame-of-a-mc/63603 "2004-09-08T10:47:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![markcq](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@markcq](https://forum.kirupa.com/u/markcq)\
**Post date:** [September 8, 2004, 10:47am UTC](https://forum.kirupa.com/t/using--xmouse-to-display-a-certain-frame-of-a-mc/63603/1 "2004-09-08T10:47:46Z")

</div>

I have a MC of 38 frames. I want a different frame to display depending on the x position of the mouse so that the user will play the MC by moving their mouse.

Any ideas?

:trout: I should be able to do this, but my brain has a huge mental block and maths is the last thing that want to stick in my poor ol’ brain. (Been concentrating too much on 3D hehehe)

---

<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:** [September 8, 2004, 11:39am UTC](https://forum.kirupa.com/t/using--xmouse-to-display-a-certain-frame-of-a-mc/63603/2 "2004-09-08T11:39:26Z")

</div>

let’s see…

onMouseMove = function() {  
num = (mc.\_totalframes/Stage.width)\*\_xmouse;  
mc.gotoAndStop(num);  
}

does that work? haven’t tested or anything 🙂

---

<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:** [September 8, 2004, 11:49am UTC](https://forum.kirupa.com/t/using--xmouse-to-display-a-certain-frame-of-a-mc/63603/3 "2004-09-08T11:49:19Z")

</div>

dankie, but don’t seem to work. maybe i’m missing something.  
i’ll have to continue scratching my head 🙂

---

<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:** [September 8, 2004, 12:09pm UTC](https://forum.kirupa.com/t/using--xmouse-to-display-a-certain-frame-of-a-mc/63603/4 "2004-09-08T12:09:17Z")

</div>

oh alright… how about this then 🙂

```auto
this.onMouseMove = function() {
	var num = Math.round((mc._totalframes/550)*this._xmouse);
	mc.gotoAndStop(num);
	updateAfterEvent();
}

```

---

<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:** [September 8, 2004, 12:10pm UTC](https://forum.kirupa.com/t/using--xmouse-to-display-a-certain-frame-of-a-mc/63603/5 "2004-09-08T12:10:51Z")

</div>

blank? :h:  
hehehe

---

<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:** [September 8, 2004, 12:45pm UTC](https://forum.kirupa.com/t/using--xmouse-to-display-a-certain-frame-of-a-mc/63603/6 "2004-09-08T12:45:52Z")

</div>

ok, i got this one to work…

onClipEvent (enterFrame) {  
xm = parseInt(\_root.\_xmouse);  
mcf = parseInt(\_root.head.\_totalframes);  
sw = 600;  
num = Math.round(xm\*(mcf/sw));  
\_root.head.gotoAndStop(num);  
}

just need to refine it a little more. i tried sw = Stage.width, but it didn’t work that well. gave me other calculations…

thanx for the help mediamonkey 🙂
