What is the code for a next and previous button? - Animate cc html5 -
Help!!
Help!!
Hi.
I'm supposing you need navigation buttons like those of e-learning training. If that's the case, put this code in the first frame of the timeline in which the buttons are located:
// prevButton and nextButton are the instance names of the buttons
this.navigationLoop = true; // set to true or false to enable or disable loop when the current position is the first or the last frame
if (!this.hasStarted)
{
this.prevFrame = function(e)
{
if (this.navigationLoop && this.currentFrame == 0)
this.gotoAndStop(this.timeline.duration - 1);
else
this.gotoAndStop(this.currentFrame - 1);
};
this.nextFrame = function(e)
{
if (!this.navigationLoop && this.currentFrame == this.timeline.duration - 1)
return;
this.gotoAndStop(this.currentFrame + 1);
};
this.prevButton.on("click", this.prevFrame, this);
this.nextButton.on("click", this.nextFrame, this);
this.stop();
this.hasStarted = true;
}
Regards,
JC
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.