PDA

View Full Version : stop yoyo



ditti
October 27th, 2005, 07:42 AM
Hi!
I have had this question in ActionScript.org Forum but didnīt get any answers so I try again here in Kirupa.
I have this code which is working alright.

var myx_tween:Object = new Tween(jojjox, "_x", Regular.easeIn, jojjox._x, jojjox_end._x, 3, true);
var myy_tween:Object = new Tween(jojjox, "_y", Regular.easeIn, jojjox._y, jojjox_end._y, 3, true);
myy_tween.onMotionFinished = function() {
myx_tween.yoyo();
myy_tween.yoyo();
};

Now I want the yoyo to stop when I press a button. I have tried with
myx_tween.stop();
myy_tween.stop();
but it doesnīt work. If someone knows how to stop it I would be quit happy.

JimmyH
October 27th, 2005, 07:50 AM
add so that when your button is pressed this is run

myx_tween = null;
myy_tween = null;

jimmy

ditti
October 27th, 2005, 08:03 AM
Thanks!!, but that didnīt help.

nathan99
October 27th, 2005, 08:38 AM
delete myx_tween.yoyo();
delete myy_tween.yoyo();
coz ur yoyo() looks to be a function? I didnt delve into this much, so it most likely wont work

ditti
October 27th, 2005, 09:50 AM
Thanks a lot, that works!

g5604
October 27th, 2005, 09:52 AM
you could also set a var to do this:

var myx_tween:Object = new Tween(jojjox, "_x", Regular.easeIn, jojjox._x, jojjox_end._x, 3, true);
var myy_tween:Object = new Tween(jojjox, "_y", Regular.easeIn, jojjox._y, jojjox_end._y, 3, true);
myy_tween.onMotionFinished = function() {
if (btnpress == true) {
myx_tween.yoyo();
myy_tween.yoyo();
}
};

ditti
October 27th, 2005, 10:18 AM
thanks for that too! I shal try it.

TheCanadian
October 27th, 2005, 05:17 PM
http://www.macromedia.com/devnet/flash/articles/tweening.html

That has information about the tween class and the yoyo method which you may find useful :).