Copy link to clipboard
Copied
Hi,
I'm using Adobe animate to make an animated novel. I need some help regarding some coding. Im using the code below to create a function that plays/loops the animation. It works fine but it seems extremely inefficient as I have to define a new function everytime I want the user to advance.
This code is on frame 199
stop ( );
nextbutton.addEventListener(MouseEvent.CLICK.nextclick);
function nextclick(event: MouseEvent):void
{
gotoAndPlay(200);
}
So each time I want the animation to stop and start ONLY when the user presses the next button, I have to define a new function like nextclick1,nextclick2,nextclick3...... I mean there HAS to be a better way of doing this. I had to create 100 function in one of the animation.
Any help would be greatly appreciated.
Copy link to clipboard
Copied
Whereas you already have your specific Frames marked with "stop();" , your function should only contain the "play()" since the idea is just to continue from the point where it is standing:
stop ( );
nextbutton.addEventListener(MouseEvent.CLICK.nextclick);
function nextclick(event: MouseEvent):void
{
play();
}
Copy link to clipboard
Copied
I'll try that today and see how it goes. Thanks for the help
Edit: Although this is somewhat helpful, but my main concern was defining NEW FUNCTION i.e nextclick, each time I want the user to advance further. e.g
FOR FRAME 1 to 100
stop ( );
nextbutton.addEventListener(MouseEvent.CLICK.nextclick);
function nextclick(event: MouseEvent):void
{
play();
}
FOR FRAME 101 to 200
stop ( );
nextbutton.addEventListener(MouseEvent.CLICK.nextclick1);
function nextclick1(event: MouseEvent):void
{
play();
}
each time i have to define new function i.e nextclick1, nextclick2..........
Can anyone help with that?
Copy link to clipboard
Copied
I believe that its function will remain, since the action performed is the same always.
Change only the names of the buttons but always calling the same function and showing the "stops" in the appropriate frames;
// Example:
stop ( );
nextbutton100.addEventListener(MouseEvent.CLICK.nextclick);
nextbutton200.addEventListener(MouseEvent.CLICK.nextclick);
nextbutton300.addEventListener(MouseEvent.CLICK.nextclick); //...
function nextclick(event: MouseEvent):void {
play();
}
Copy link to clipboard
Copied
Bump