Copy link to clipboard
Copied
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?
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();
}
Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
ClayUUID​, works perfect, thank you very much!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now