I'm trying to disable a tween from continuing. The clock is remove from the screen but the function still fires.
I tried to do this below but after my "timerlength" is up I still hear the audio.
clockContainer.removeAllChildren();
self.stage.removeChild(mytweentodisable);
Not sure how to refactor it to stop the function from continuing.
mytweentodisable = createjs.Tween.get(clockHand, { loop: false }).to({ rotation: 360 }, TimerLength).call(function () {
//this will trigger the timer is up
if (gameIsRunning == true) {
createjs.Sound.stop();
gameIsRunning = false;
createjs.Sound.play("gameOver");
}
});
Hopefully I understood you goal :]
Removing tweens from an object is quite simple, and is done by calling:
Tween.removeTweens(target)
As described in TweenJS docs:
removeTweens ( target )
Defined in removeTweens:444 Removes all existing tweens for a target. This is called automatically by new tweens if the override property is true. Parameters:
target [Object]
The target object to remove existing tweens from.
Reference: http://www.createjs.com/docs/tweenjs/classes/Tween.html#method_removeTweens
You can see a very simple example Iv'e setup here: http://jsfiddle.net/2ot8pr0h/2/
(Clicking on the button will remove the tweens from all balls).