I have created a tween animation like this:
var tweenLight = new createjs.Tween(mycolor,{loop:9})
.to({r:1},500)
.to({r:0},500)
.addEventListener('complete',function() {
// code to be executed when tween is completed
});
tweenLight.addEventListener('change',function() { // <--- not a function
// code to be executed each frame
});
When this code is executed, it gives me an error, addEventListener is not a function, on line 7, so the update event is not registered so the animation doesn't run my update code. It does however run the code on 'complete' when the animation ends.
However, if I do any of these things:
(..).addEventListener('complete',function() {
}).addEventListener('change',function() { // <--- still not a function
});
.
(..).addEventListener('complete',function() {
})
tweenLight.addEventListener('change',function() { // <--- still not a function
});
It will always give an error in the last 'addEventListener'. So if I add 'update' first, the animation will work properly but won't execute the completion code.
Both 'update' and 'complete' are events according to the docs.
Why can I only add one of the events?
My guess is it does not return the tween object, but some other event reference so break up the chain
var tweenLight = new createjs.Tween(mycolor, {
loop: 9
})
.to({
r: 1
}, 500)
.to({
r: 0
}, 500);
tweenLight.addEventListener('complete', function() {
// code to be executed when tween is completed
});
tweenLight.addEventListener('change', function() { // <--- not a function
// code to be executed each frame
});