Skip to main content
Participant
February 7, 2019
Answered

Dynamic Text Box Not Updating

  • February 7, 2019
  • 6 replies
  • 1396 views

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

}

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer avid_body16B8

redid his example in html5 with dynamic text and feedbacks.

MULTIPLE CHOICE EXAMPLE.zip - Box

6 replies

kdmemory
Inspiring
February 7, 2019

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

Inspiring
February 7, 2019

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.

Community Expert
February 7, 2019
avid_body16B8
avid_body16B8Correct answer
Legend
February 7, 2019

redid his example in html5 with dynamic text and feedbacks.

MULTIPLE CHOICE EXAMPLE.zip - Box

thekay666Author
Participant
February 7, 2019

Thanks to everyone who has replied.

Using the example provided by 'redesign' I have got the hang of it