Skip to main content
March 11, 2020
Question

Actionscript 3.0 help. how to move to next frame and play on mouse click

  • March 11, 2020
  • 2 replies
  • 8080 views

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.

    This topic has been closed for replies.

    2 replies

    New Participant
    March 15, 2020

    Bump

    AdrianaCampolina
    Participating Frequently
    March 11, 2020

    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();

    }

     

    March 14, 2020

    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?

    AdrianaCampolina
    Participating Frequently
    March 17, 2020

    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();

    }