Copy link to clipboard
Copied
Hi, I'm from an actionscript background and only just getting to grips with Animate with HTML5 Canvas
I'm creating a simple maths quiz and having a problem displaying the updated score inside a dynamic text box.
I know the score variable is adding +1 (I'm using alert(score) to test this) but it isn't updating inside the dynamic text box (named countText in the properties panel).
Any pointers in the right direction would be appreciated.
Example code:
// check the question count
function scoreCheck() {
score++;
alert(score);
this.countText = score; // this textfeld is not updating
}
1 Correct answer
redid his example in html5 with dynamic text and feedbacks.
Copy link to clipboard
Copied
Try this tutorial. Animate CC(HTML5) self scoring simple multiple choice quiz. - YouTube
Copy link to clipboard
Copied
redid his example in html5 with dynamic text and feedbacks.
Copy link to clipboard
Copied
Thanks to everyone who has replied.
Using the example provided by 'redesign' I have got the hang of it
Copy link to clipboard
Copied
My pleasure! Good luck on your project.
Copy link to clipboard
Copied
Hi thekay
do it so:
function scoreCheck() {
score++;
console.log(score); // tip: use console instead of alert
this.countText.text = score; // add property text
}
Klaus
Copy link to clipboard
Copied
Just to add to the above.
I know it's obvious but remember to declare the variable score (for a global variable put in the Global:Script part in the Actions panel).
Also if using this. in the function then use .bind(this) in the event listener.
e.g. this.plusBtn.on("click",scoreCheck.bind(this));
plusBtn is just something I made up as a button instance.
Hopefully we have helped.
Cheers.

