Skip to main content
johnb25407957
Participant
October 4, 2015
Answered

How do I resume animation on mouse click?

  • October 4, 2015
  • 1 reply
  • 1063 views

I created a simple animation of water flowing through pipes and need it to pause at certain points then resume on a mouse click. How do I do that with actionscript 3.0?

This topic has been closed for replies.
Correct answer Ned Murphy

Use the play() command in the event handler...

resumeBtn.addEventListener(MouseEvent.CLICK, resumeAnimation);

function resumeAnimation(evt:MouseEvent):void {

       play();

}

If you do not have a button for this and just want to click anywhere try changing the event listener to...

stage.addEventListener(MouseEvent.CLICK, resumeAnimation);

1 reply

kglad
Community Expert
Community Expert
October 4, 2015

either place stop() on the water movieclip's timeline where you want that pause or use an enterframe loop to repeatedly check that movieclips currentFrame.

johnb25407957
Participant
October 5, 2015

Thank you for that, but then how do I resume with a mouse click?

Ned Murphy
Ned MurphyCorrect answer
Legend
October 5, 2015

Use the play() command in the event handler...

resumeBtn.addEventListener(MouseEvent.CLICK, resumeAnimation);

function resumeAnimation(evt:MouseEvent):void {

       play();

}

If you do not have a button for this and just want to click anywhere try changing the event listener to...

stage.addEventListener(MouseEvent.CLICK, resumeAnimation);