Trouble with using variable to store Frame label and then gotoAndPlay(variable) Animate HTML5 Canvas
Hello, I'm in the midst of trying to convert an AS3 project to HTML5 Canvas. Mostly working, but variables are giving me trouble. I imagine it's something simple in my technique or coding, but I've searched threads and not found any question similar enough for their solutions to work. I'll add that WHile I've used Flash a lot in the past, this project is my first in about 10 years, and the first time I've used HTML5 Canvas. So my knowledge is quite limited.
So... I have a realtively simple timeline, image animations of medical equipment coming in and out with stops in the timeline to give specifications and allow buttons to be clicked to choose what to see next. In the first frame I declare a variable:
window.destination = "Config111";
where Config111 is a frame label. A few frames later, I use this command:
this.gotoAndPlay(window.destination);
and when testing the movie it works. I end up at the expected frame. But now my problems start. On the frame labeled Config111, there is a stop action, and I have the several buttons each one with a click handler like this:
this.stop();
this.UD0_btn.addEventListener("click", UD0_btn_clicked3.bind(this));
function UD0_btn_clicked3() {
window.destination = "Config011";
this.play();
}
When a user clicks a button, the timeline starts to play again, the medical equipment is removed, and then there's a keyframe with script to remove the event handlers and instruct the timeline to gotoAndPlay the destination frame:
this.UD0_btn.removeEventListener("click", UD0_btn_clicked3);
this.gotoAndPlay(window.destination);
At this point, the gotoAndPlay command seems to be ignored, and the timeline keeps playing till it reached the next stop();. So I don't know if my problem is that I'm setting the variable to something that isn't understood, or if I'm somehow using the gotoAndPlay command incorrectly. I do have my frame labels on a separate layer from my scripts, and my scripts layer is called "scripts" and labels layer called "labels" if that makes any difference.
Thanks immensly for any help/direction you can give.
Pietr
