Highlighted

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

New Here ,
Mar 11, 2020

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.

Views

213

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

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

New Here ,
Mar 11, 2020

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.

Views

214

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mar 11, 2020 0
Community Beginner ,
Mar 11, 2020

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

}

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 11, 2020 1
New Here ,
Mar 13, 2020

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 13, 2020 1
Community Beginner ,
Mar 17, 2020

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

}

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 17, 2020 0
New Here ,
Mar 15, 2020

Copy link to clipboard

Copied

Bump

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 15, 2020 0