Mouse-triggering actions (continued)

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

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

Ah…it worked :slight_smile: \r\rThank you!\r\rAchnor

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

The problem is in your test. Just look at that

 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]


That was fast.\r\rpom 0]