Animate beginners javascript function issue
Hi – I've just started with playing around with javascript in Animate (not sure it's even the right software for the animation I want to do yet!), but am having a beginners' issue with getting functions to run. I've adapted some of the code from this tutorial.
When I use this code in the first keyframe to change the text on a Dynamic Text box called 'yearText' it works fine:
var currentYear = 2017;
var year = 1971;
this.yearText.text = year;
this.playBtn.addEventListener("click", playClicked.bind(this));
function playClicked() {
this.play();
isPlaying = true;
year = year + 1;
this.yearText.text = year;
}
But then if I put a function inside the function in place of the last two lines like this, it no longer works:
this.playBtn.addEventListener("click", playClicked.bind(this));
function playClicked() {
this.play();
isPlaying = true;
year = year + 1;
this.yearText.text = year;
}
function yearIncrease() {
year = year + 1;
this.yearText.text = year;
}
Have I completely misunderstood something about how functions work?
Any help very much appreciated! Then i can see if Animate is something I'll be able to use properly...