# Reversing frames on button release

**URL:** https://forum.kirupa.com/t/reversing-frames-on-button-release/58625
**Category:** flash
**Created:** [July 24, 2004, 6:55am UTC](https://forum.kirupa.com/t/reversing-frames-on-button-release/58625 "2004-07-24T06:55:57Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 24, 2004, 8:15pm UTC](https://forum.kirupa.com/t/reversing-frames-on-button-release/58625/2 "2004-07-24T20:15:49Z")

</div>

A quick copy&past from some code I posted on another forum. So just ignore the Dutch comments 😛 Should help you a bit. Demo here: [http://www.henxcom.com/mediamonkey/flashfiles/playfuncties.html](http://www.henxcom.com/mediamonkey/flashfiles/playfuncties.html)

[AS]// dit moet je zelf goed invullen!!!  
var fps = 30;

// vervangt de standaard play() van een movieclip  
function playForward(mc) {  
clean(mc);  
mc.play();  
}

// functie om terug af te spelen.  
function playBackward(mc, halt) {  
mc.onEnterFrame = function() {  
if (this.\_currentframe == 1) {  
(halt) ? delete this.onEnterFrame : this.gotoAndStop(this.\_totalframes);  
}  
clearInterval(\_root.ff);  
clearInterval(\_root.fb);  
this.prevFrame();  
}  
}

// “stopt” (pauzeert) de mc/swf  
function pauze(mc) {  
clean(mc);  
mc.stop();  
}

// stopt de mc echt, en gaat terug naar het 1e frame  
function stoppen(mc) {  
clean(mc);  
mc.gotoAndStop(1);  
}

// deze functie speelt de mc versneld af  
// gebruik ‘speed’ als factor: bv 2 voor 2x zo snel, of 0.5 voor de helft zo snel  
// gebruik ‘halt’ als boolean om de animatie wel of niet te loopen  
function fastForward(mc, speed, halt) {  
clean(mc);  
var time = 1000/fps/speed;  
ff = setInterval( function() {  
mc.nextFrame();  
if (mc.\_currentframe == mc.\_totalframes) {  
(halt) ? clearInterval(ff) : mc.gotoAndStop(1);  
}  
}, time);  
}

// deze functie speelt de mc versneld terug af  
// gebruik ‘speed’ als factor: bv 2 voor 2x zo snel, of 0.5 voor de helft zo snel  
// gebruik ‘halt’ als boolean om de animatie wel of niet te loopen  
function fastBackward(mc, speed, halt) {  
clean(mc);  
var time = 1000/fps/speed;  
fb = setInterval( function() {  
mc.prevFrame();  
if (mc.\_currentframe == 1) {  
(halt) ? clearInterval(fb) : mc.gotoAndStop(mc.\_totalframes);  
}  
}, time);  
}

// verwijdert alle intervallen en de onEnterFrame, als die wordt gebruikt  
function clean(mc) {  
if (mc.onEnterFrame) mc.onEnterFrame = null;  
if (ff) clearInterval(ff);  
if (fb) clearInterval(fb);  
}

// Als je die interval geen mooie oplossing vind kun je ook een  
// functie bedenken die berekent op welke frame de mc/swf moet staan  
// en er direct naar verwijst.[/AS]

---

_[View the full topic](https://forum.kirupa.com/t/reversing-frames-on-button-release/58625)._
