I'm trying to incorporate buttons into HTML Canvas, that will allow users to speed up or slow down my animated lesson. I was able to do this with Adobe Animate using the following code. Obviously Action Script won't work with HTML Canvas; I'm just including it here to demonstrate where I'm starting and hopefully make it clearer what I want to do.
I've searched this Community Forum using various search terms such as "frame rate" and "fps," but I didn't find any conversations that answered my question. I'm probably just not using the correct search terms. Anyway, if someone could provide guidance I would really appreciate it.
In the HTML5 Canvas document, each Movie Clip instance can have a different FPS. So, for example, you could code something like this:
var root = this;
var anim = root.anim; // the anim can be the main timeline itself
var button = root.button;
var slowFPS = 10;
e.currentTarget.toggled = !e.currentTarget.toggled;
anim.framerate = e.currentTarget.toggled ? slowFPS : lib.properties.fps;