Button is pressed once, but Animate registers multiple clicks
I am using Animate CC and an HTML canvas. I have buttons that are common on all of my "pages" - home, previous and next. The home button works fine. However, the same is not true for the previous and next buttons. The code is contained within a frame named actions which is part of the timeline. In a frame towards the start of the timeline I define the actions for the previous and next buttons. What I am seeing is that on some of the "pages" when I press the next (or previous) button it is behaving as if I performed several clicks. In the code for the buttons, I have added window.alert calls to help with the debugging (one states the button was pressed, one states the current frame name, and a third displays the frame label I am going to). When I press, for example, next, I see the three alerts that I would expect. However, I then immediately see another set of alerts, as if I had pressed the next button again (but I have not). The implementation is currently skipping over several of my pages (that is, I see the alerts as if I had pressed the next button four times). For those unexpected alerts, I do see, as the current label, the pages that are being skipped. Thus, it is going to the correct page, but then for some reason it thinks that the next button was pressed again and proceeds to the next page.
Here is what the code looks like for the next button (the code for previous is basically identical, only with different target pages to go to):
_this.moveforward_btn.on('click', function(){
_this.stop()
createjs.Sound.stop() // one page has audio in the timeline
window.alert("move foward pressed: ")
window.alert("move foward pressed, currentLabel: "+_this.currentLabel)
switch (_this.currentLabel) {
case "home":
nextLabel = "bio"
break
case "bio":
nextLabel = "contact"
break
case "contact":
nextLabel = "projects"
break
case "projects":
nextLabel = "boardwalk"
break
case "boardwalk":
nextLabel = "octopus"
break
case "octopus":
nextLabel = "cars"
break
case "cars":
nextLabel = "alien"
break
case "alien":
nextLabel = "currency"
break
case "currency":
nextLabel = "hamlet"
break
case "hamlet":
nextLabel = "snowangel"
break
case "snowangel":
nextLabel = "weightlifter"
break
case "weightlifter":
nextLabel = "biking"
break
case "biking":
nextLabel = "walking"
break
case "walking":
nextLabel = "juno"
break
case "juno":
nextLabel = "fire"
break
case "fire":
nextLabel = "shoes"
break
case "shoes":
nextLabel = ""
break
default:
nextLabel = ""
}
window.alert("move foward pressed, next label: "+nextLabel)
if (nextLabel != "") {
if (nextLabel == "hamlet") {
_this.gotoAndPlay(nextLabel)
} else {
_this.gotoAndStop(nextLabel)
}
}
});
Any theories as to why Animate is behaving as if the buttons were pressed multiple times in some instances? Is there a way to explicitly reset the property that indicates a button has been pressed?
Thank you,
Al
