Copy link to clipboard
Copied
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?
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);
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thank you for that, but then how do I resume with a mouse click?
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
Awesome! Thank you very much! I needed the click anywhere code snippet.