Lately I had been working on flash websites that require a user to pause a movie on what ever frame it is on then continue on another press of a button.

So I thought I would post this code as it has come in handy on all my projects for major websites:

Quote:
/*
This code goes on the start on the movie clip or root
The buttons instance is called ‘actionBtn’ on line 2 of the AS you will see this
*/

var theCase:String = “doPlay”;
actionBtn.onRelease = function() {
if (_level0.theCase == “doPlay”) {
_level0.theCase = “doPause”;
} else {
_level0.theCase = “doPlay”;
}
trace(_level0.theCase);
};
this.onEnterFrame = function() {
if (_level0.theCase == “doPause”) {
this.stop();
} else {
this.play();
}
};

Join the conversation! 5,768 Comments