Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dynamic Text Box Not Updating

Community Beginner ,
Feb 07, 2019 Feb 07, 2019

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.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Feb 07, 2019 Feb 07, 2019

redid his example in html5 with dynamic text and feedbacks.

MULTIPLE CHOICE EXAMPLE.zip - Box

Translate
Community Expert ,
Feb 07, 2019 Feb 07, 2019
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 07, 2019 Feb 07, 2019

redid his example in html5 with dynamic text and feedbacks.

MULTIPLE CHOICE EXAMPLE.zip - Box

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 07, 2019 Feb 07, 2019

Thanks to everyone who has replied.

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 07, 2019 Feb 07, 2019
LATEST

My pleasure! Good luck on your project.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Feb 07, 2019 Feb 07, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 07, 2019 Feb 07, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines