I've created some tweens but I need to stop them
As I need to reuse some assets with new tweens. override:true helps for some, however,
This is the function, once it has been set off, with timers, they play regardless, as you can see there's alot of call backs
window.autoSurfaces = function(){
if(!window.gameStarted){
console.log("autoSurfaces");
playAutoScene();//start playing function to control numbers and alpha of wheels
var delay = 700
var animtime = 500
currentTween = createjs.Tween.get(leaves_anim).to({alpha:.7}, animtime).wait(800).call(leavesOut);//call end frame function
tweenAray.push(currentTween)
console.log(currentTween)
leaves_anim.gotoAndPlay("go");
function leavesOut(){
currentTween = createjs.Tween.get(leaves_anim).to({alpha:0}, animtime).wait(200).call(snowIn);
tweenAray.push(currentTween)
console.log(currentTween)
}
function snowIn(){
currentTween = createjs.Tween.get(snow_anim).to({alpha:1}, animtime).wait(800).call(snowOut)
tweenAray.push(currentTween)
console.log(currentTween)
snow_anim.gotoAndPlay("go");
}
function snowOut(){
currentTween = createjs.Tween.get(snow_anim).to({alpha:0}, animtime).wait(delay).call(stopAll);
tweenAray.push(currentTween)
//console.log("fired");
function stopAll(){
playAutoOut();
leaves_anim.gotoAndStop(0);
snow_anim.gotoAndStop(0);
}
}
}
}
I set a global var of currentTween then:
currentTween = createjs.Tween.get(target).to({alpha:.7}, animtime).wait(800).call(callHandler);
then:
removeTweens(currentTween);
tried setting an array - tweenAray.push(currentTween)
tweenAray.removeTweens(currentTween)
Also createjs.Tween.removeAllTweens();
Even
createjs.Tween.removeAllTweens = function() {
var tweens = createjs.Tween._tweens;
for (var i=tweens.length-1; i>=0; i--) {
tweens[i]._paused = true;
tweens.splice(i,1);
}
};
Nothing happens or I get errors I'm exporting from Flash CS6
Any pointers?
Cheers
I'm not sure I totally understand your question, but here's a quick stab at it...
Using override will cause a new tween to stop any previous tweens with the same target. Ex.
createjs.Tween.get(foo).to({x:100, alpha:0.5}, 200);
createjs.Tween.get(foo, {override:true}).to({x:500}, 500);
The second tween will override the first tween, because they both target foo
. The first tween will not run.
If you want to stop tweens, just hold onto references to the tweens, and use setPaused(true)
. That effectively kills the tween.
var tweensToKill = [];
tweensToKill.push( new createjs.Tween.get(foo).etc(...) );
tweensToKill.push( new createjs.Tween.get(bar).etc(...) );
// ... later:
while (tweensToKill.length) {
tweensToKill.pop().setPaused(true);
}