I have implemented some tweens but now I need to pause them
Because I want to reuse certain assets with new tweens. The 'override:true' option helps in some cases, but...
This is the issue: once the function is triggered and the timers are set, the tweens play continuously regardless of callbacks.
window.autoSurfaces = function(){
if(!window.gameStarted){
console.log("autoSurfaces");
playAutoScene();//function to initiate number and alpha controls for wheels
var delay = 700
var animtime = 500
currentTween = createjs.Tween.get(leaves_anim).to({alpha:.7}, animtime).wait(800).call(leavesOut);//callback to 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)
function stopAll(){
playAutoOut();
leaves_anim.gotoAndStop(0);
snow_anim.gotoAndStop(0);
}
}
}
}
I initialized a global variable named currentTween and then:
currentTween = createjs.Tween.get(target).to({alpha:.7}, animtime).wait(800).call(callHandler);
and after that:
removeTweens(currentTween);
I attempted to use an array - tweenArray.push(currentTween)
tweenArray.removeTweens(currentTween)
Moreover, 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);
}
};
However, nothing seems to work or sometimes errors occur. I am exporting from Flash CS6.
Any suggestions?
Cheers