Is there an event for frame change?
I am building a menu using HTML5 canvas.
The menu has tons of submenus, each of which has a bunch of buttons.
Each button gets an event listener added to it when that frame loads.
Every time the user hits a button, the main timeline skips to a different frame (a different submenu).
From what I've read, I need to remove the event listeners for the buttons that are no longer visible when this happens.
That means most of my buttons need to have code that removes all event listeners, and only then changes frames.
This is bad, since I might forget to add this code to one of my buttons at some point, and the next time I come back to that menu, it'll add a second event listener for the button, making the function that handles the button click fire twice.
Is it possible to add an event listener that triggers when the frame changes? If so, I could just clear all event listeners that I setup on any buttons anywhere every time the frame changes, and not have to do it within each button's code.
