HTML5 Canvas: How to disable stage.on("click", function(){...
Hello,
I am working with some already written code as part of a larger project which includes a main timeline with 10 frames, navigation arrows for the user to cycle forward and backward through those 10 frames, and nested movieclips with interactive elements on each main timeline frame. (Essentially, each main timeline frame is a new game.)
Anyways, some code in a game on frame 2 is causing issues with my games in later frames. I am working with previously written code (I am also a beginner to HTML5 Canvas with CreateJS) and I would like to remove the event listener from the stage, or disalbe this event in subsequent frames:
This is the code causing me issues:
stage.on("click", function(){
... //lots of things happening here
}
I would like to disable this stage event, or remove the event listener from the stage so that it does not interfere with later frames. I tried to rewrite the above like this:
stage.addEventListener("click", ThingsHappen);
function ThingsHappen() {
}
..and then remove it like this:
stage.removeEventListener("click", ThingsHappen);
But I am not having success. Is it possible to remove an .on event from the stage? or to add an EventListener to the actual stage? The original code [stage.on("click", function(){}] does do what it should in the frame in which it is called, however I need to remove it in order for some subsequent stage functions to work. Thank you! Again, I am still learning as I go, so please be kind. Thank you in advance.