Highlighted

Dynamic Text Box Not Updating

Community Beginner ,
Feb 07, 2019

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

}

Adobe Community Professional
Correct answer by resdesign | Adobe Community Professional

redid his example in html5 with dynamic text and feedbacks.

MULTIPLE CHOICE EXAMPLE.zip - Box

Views

264

Likes

Translate

Translate

Report

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

Dynamic Text Box Not Updating

Community Beginner ,
Feb 07, 2019

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

}

Adobe Community Professional
Correct answer by resdesign | Adobe Community Professional

redid his example in html5 with dynamic text and feedbacks.

MULTIPLE CHOICE EXAMPLE.zip - Box

Views

265

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 07, 2019 0
Adobe Community Professional ,
Feb 07, 2019

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 07, 2019 2
Adobe Community Professional ,
Feb 07, 2019

Copy link to clipboard

Copied

redid his example in html5 with dynamic text and feedbacks.

MULTIPLE CHOICE EXAMPLE.zip - Box

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 07, 2019 1
Community Beginner ,
Feb 07, 2019

Copy link to clipboard

Copied

Thanks to everyone who has replied.

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 07, 2019 0
Adobe Community Professional ,
Feb 07, 2019

Copy link to clipboard

Copied

My pleasure! Good luck on your project.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 07, 2019 0
Advocate ,
Feb 07, 2019

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 07, 2019 2
Engaged ,
Feb 07, 2019

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 07, 2019 2