Skip to main content
_aarmstrong
Participant
April 7, 2018
Answered

gotoAndStop if statement

  • April 7, 2018
  • 1 reply
  • 901 views

Hi all, using a score to direct people to their correct finished screen. I am using HTML5 canvas and CreateJS.

this.nxt.addEventListener("click", fl_ClickToGoToAndStopAtFrame.bind(this));

function fl_ClickToGoToAndStopAtFrame()

{

    if (score >= 3) {

        gotoAndStop(50);

    } else if (score <= 4 && score >= 😎 {

        gotoAndStop(51);

    } else {

        gotoAndStop(52);

    }

}

However, it seems it doesnt want to play ball, any help is greatly appreciated. Thankyou.Adobe Animate CC - Home

This topic has been closed for replies.
Correct answer Colin Holgate

I think that with JavaScript 'this' is never implied. So, this.gotoAndStop(50) might work better.

Also, read your lines and think through what will happen. You have two tests that a score of 4 would match, and you have a line where you're testing for <=4 and >=8. What number could match both of those things?

1 reply

Colin Holgate
Colin HolgateCorrect answer
Inspiring
April 7, 2018

I think that with JavaScript 'this' is never implied. So, this.gotoAndStop(50) might work better.

Also, read your lines and think through what will happen. You have two tests that a score of 4 would match, and you have a line where you're testing for <=4 and >=8. What number could match both of those things?

_aarmstrong
Participant
April 7, 2018

Thanks for that, I knew something didnt look right.