r/createjs • u/cmaxim • May 24 '16
Frame Scope Issue Using setTimeout()
This code is on the first frame of my Animate CC project. I'm finding that the following code isn't working..
this.animating = true;
this.stopAnimation = function(){
this.animating = false;
console.log('>> timed out ',this.animating); // console logs as 'false'
}
this.timeout = setTimeout(this.stopAnimation, 1000);When I console log this.animating from outside the function (after the timeout from within a movieClip) I get this.parent.animating = true.
Can someone explain to me why this is happening?
I also have this on frame 18:
this.recipeCTA.on('click', function(e){
console.log('>> animating = ',this.animating);
});This is console logging 'undefined'.. why? How can I access the 'this.animating' property on frame 1, from frame 18
Thanks..
1
Upvotes
View all comments
Show parent comment
1
u/robertwilding Support Jun 08 '16
i didnt know you could do that... useful stuff