• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Mar 11, 2020 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

6.5K

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
community guidelines
Explorer ,
Mar 11, 2020 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();

}

 

Votes

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
community guidelines
New Here ,
Mar 13, 2020 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?

Votes

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
community guidelines
Explorer ,
Mar 17, 2020 Mar 17, 2020

Copy link to clipboard

Copied

LATEST

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

}

 

Votes

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
community guidelines
New Here ,
Mar 15, 2020 Mar 15, 2020

Copy link to clipboard

Copied

Bump

Votes

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
community guidelines