# Mouse-triggering actions (continued)

**URL:** <https://forum.kirupa.com/t/mouse-triggering-actions-continued/2895>\
**Category:** Uncategorized\
**Created:** [March 15, 2002, 6:23am UTC](https://forum.kirupa.com/t/mouse-triggering-actions-continued/2895 "2002-03-15T06:23:05Z")\
**Posts on this page:** 7\
**Page:** 1

<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:** [March 15, 2002, 6:23am UTC](https://forum.kirupa.com/t/mouse-triggering-actions-continued/2895/1 "2002-03-15T06:23:05Z")

</div>

I have a graphic (220px \* 40px) in frame 1 tweened to frame 10.\rIn frame 1 I have the following script:\r\*\*\*\*\*\*\*\*\*\*\rif (\_xmouse\>0 && \_xmouse\<220 && \_ymouse\>0 && \_ymouse\<40) {\r play ();\r} else {\r stop ();\r}\r\*\*\*\*\*\*\*\*\*\*\rThe idea is to trigger the tween when the mouse is over the graphic but nothing happens?\r\rAchnor

---

<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:** [March 15, 2002, 6:31am UTC](https://forum.kirupa.com/t/mouse-triggering-actions-continued/2895/2 "2002-03-15T06:31:04Z")

</div>

put it in frame 2 and do this:\rif (\_xmouse\>0 && \_xmouse\<220 && \_ymouse\>0 && \_ymouse\<40) {\rplay ();\r} else {\rgotoAndPlay(\_currentframe-1);\r}\r\ralso, start the animation in frame 2 rather than frame 1.\r:) \rjeremy

---

<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:** [March 15, 2002, 6:41am UTC](https://forum.kirupa.com/t/mouse-triggering-actions-continued/2895/3 "2002-03-15T06:41:41Z")

</div>

Ah…it worked 🙂 \r\rThank you!\r\rAchnor

---

<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:** [March 15, 2002, 8:04am UTC](https://forum.kirupa.com/t/mouse-triggering-actions-continued/2895/4 "2002-03-15T08:04:51Z")

</div>

Strange. In then 10th frame I want to do the opposite, e.g. if the mouse is _outside_ a certain area, I would like the tween to continue playing to frame 20. I just cut’n’pasted the prior code but for some reason it wont work?\r\r\*\*\*\*\*\*\*\*\*\rif (\_xmouse\<230 && \_xmouse\>380 && \_ymouse\<0 && \_ymouse\>100) {\rplay ();\r} else {\rgotoAndPlay(\_currentframe-1);\r}\r\*\*\*\*\*\*\*\*\*\r\rI thought perhaps the problem was \_ymouse\<0 but thats not it. I’ve also experimented with inserting non-tweened frames in between the two tweens (lol) in case the “gotoAndPlay(\_currentframe-1)” wouldn’t accept going back to a tweened frame but no, didn’t help.\r\rSpeak to me O’knowledgeble one!\r\rYour humble Achnor

---

<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:** [March 15, 2002, 8:47am UTC](https://forum.kirupa.com/t/mouse-triggering-actions-continued/2895/5 "2002-03-15T08:47:19Z")

</div>

The problem is in your test. Just look at that

```auto
 if (_xmouse<230 && _xmouse>380 && _ymouse<0 && _ymouse>100)

```

It means "if the mouse’s x position is \< 230 and \> 380… That’s never true. The mouse cannot be at the same time \>380 and \<230. You have to remove the && and put the boolean or instead (that’s two vertical lines). Because the fact that \*\* one of the conditions\*\* is true means that your outside the clip area. Then it might work.\r\rpom 0]

---

<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:** [March 15, 2002, 8:50am UTC](https://forum.kirupa.com/t/mouse-triggering-actions-continued/2895/6 "2002-03-15T08:50:37Z")

</div>

Doh!\r\rThanks.\r\rAchnor

---

<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:** [March 15, 2002, 8:51am UTC](https://forum.kirupa.com/t/mouse-triggering-actions-continued/2895/7 "2002-03-15T08:51:25Z")

</div>

That was fast.\r\rpom 0]
