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

Animate Canvas HTML5 - Stop on specified frame when mouseclick

Explorer ,
Oct 11, 2018 Oct 11, 2018

I have an Adobe Animate Canvas animation, 100 frames.

Normally the animation should play from frame 1 to frame 100

Only if the user hits a certain button the animation should only play till frame 50.

What code should I use?

385
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 , Oct 16, 2018 Oct 16, 2018

In the first frame:

if (!this.myButton.hasEventListener("click")) {

    this.myButton.addEventListener("click", myButtonClicked.bind(this));

}

function myButtonClicked() {

    this.stopAt50 = true;

}

If your timeline doesn't loop, you don't need the check around the listener assignment.

Then on frame 50:

if (this.stopAt50) {

    this.stop();

}

Translate
LEGEND ,
Oct 16, 2018 Oct 16, 2018

In the first frame:

if (!this.myButton.hasEventListener("click")) {

    this.myButton.addEventListener("click", myButtonClicked.bind(this));

}

function myButtonClicked() {

    this.stopAt50 = true;

}

If your timeline doesn't loop, you don't need the check around the listener assignment.

Then on frame 50:

if (this.stopAt50) {

    this.stop();

}

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
Explorer ,
Oct 23, 2018 Oct 23, 2018
LATEST

ClayUUID​, works perfect, thank you very much!

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