VarTween starts by itself when added


(Elias) #1

Every tween i add in the gameworld, starts automatically by itself. Even if i throw a false at the autostart it seems that it’s ignoring it and still starts by itself. Is it a bug or something?


(Bora Kasap) #2

what you mean with “autostart”, tween class have a boolean named “active”, not “autostart”? Or i miss something?


(Elias) #3

Yeah, it’s not called autostart, obviously. Anyway when you add a tween you got the option to start it immediately. Even if throw a false in there it’s still starts.

addTween(myTween, false);


(Bora Kasap) #4

ah, i got it, i suggest, you right click myTween and find all references… maybe you’re starting tween from somewhere else? interesting problem


(Elias) #5

Basically i construct my tween. Then i put the properties of my choice and in the end i add the tween.

var myTween:varTween = new varTween();

myTween.tween(myObject, x, 500, 2, null);

add(myTween, false);

When i add the tween, no matter if it false or truth, it’s still starts by itself.


(Bora Kasap) #6

think about that… maybe this autostart thing is works only for “start”, i mean, it may not stopping working tweens…

so, try this…

var myTween:VarTween = new VarTween();

myTween.tween(myObject, x, 500, 2, null);
myTween.active = false;

add(myTween, false);

(Bora Kasap) #7

yeah… look that. decleration of addTween function… as you see, it doesn’t stop working tweens, only for start…

public function addTween(t:Tween, start:Boolean = false):Tween
		{
			if (t._parent) throw new Error("Cannot add a Tween object more than once.");
			t._parent = this;
			t._next = _tween;
			if (_tween) _tween._prev = t;
			_tween = t;
			if (start) _tween.start();
			return t;
		}

or you can implement this with: if(start) _tween.start(); else _tween.stop();

but i’m not suggesting you do that… because some original FP functions may supporting by this function, so … it is better you use myTween.active = false;


(Elias) #8

Yeah, i am not gonna change anything in the library. If it’s gonna work properly by deactivating it before even add it, it’s cool. Thanks for your help, i am gonna try it right away. :smile:


(Jonathan Stoler) #9

If you add the tween first, it won’t run until you call it. (the start argument of addTween is default false)

myTween = new VarTween();
addTween(myTween);

// when you want to run it...
myTween.tween(obj, prop, val, time, callback);