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

this.gotoAndStop(20); is this incorrect for a gotoandstop code for html5 canvas?

Explorer ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

It's not working for me i'm not sure why I was using it if it never worked. Did it change or something?

this.gotoAndStop(20);

Views

534

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
community guidelines

correct answers 1 Correct answer

LEGEND , Jul 20, 2017 Jul 20, 2017

It's the correct syntax for going to the 21st frame. If your last frame is really 20, then you would want this.gotoAndStop(19). CreateJS frame numbers start from zero.

Another possible cause would be if the this.gotoAndPlay(20) is inside a function, and in the listener that takes you to the function you didn't bind 'this'. For example:

this.someBtn.addEventListener("click",gosomewhere.bind(this));

function gosomewhere(){

this.gotoAndStop(20);

}

should work, the bind(this) part would make the function

...

Votes

Translate

Translate
LEGEND ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

It's the correct syntax for going to the 21st frame. If your last frame is really 20, then you would want this.gotoAndStop(19). CreateJS frame numbers start from zero.

Another possible cause would be if the this.gotoAndPlay(20) is inside a function, and in the listener that takes you to the function you didn't bind 'this'. For example:

this.someBtn.addEventListener("click",gosomewhere.bind(this));

function gosomewhere(){

this.gotoAndStop(20);

}

should work, the bind(this) part would make the function use the main timeline's 'this' instead of the function's own 'this'.

Votes

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
community guidelines
Explorer ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

ok I see the issue. I think when i was using actionscript it stopped on the actual frame instead of starting frame 0.

Votes

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
community guidelines
Explorer ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

another thing that is different is the last frame (lets say its on frame 30) where im adding this.gotoAndPlay("startAnimation");

In actionscript it would go to frame 30 then execute this.gotoAndPlay("startAnimation");

in html5 canvas it never actual reaches frame 30 it executes this.gotoAndPlay("startAnimation"); before it reaches frame 30. So anything i have on frame 30 doesn't show up. This really isn't a problem now that i know whats going on but it threw my off as to why the stuff on frame 30 wasn't showing up.

Votes

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
community guidelines
LEGEND ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

LATEST

It used to be that way in ActionScript as well. It wasn't until Flash Player 10 that code was aware of the frame you had just jumped to. In Flash Player 9 you had to wait around for a frame before being able to do things.

Votes

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
community guidelines