Playing frames in reverse

Over the past few weeks i have seen this question asked a few times. To save repeating myself here’s code and example fla’s

So you want to play an mc in reverse
There are two ways to do this.
1. onEnterFrame

  1. someButton.onRollOver = function() {
  2.  playMC("for");
  3. };
  4. someButton.onRollOut = function() {
  5.  playMC("back");
  6. };
  7. function playMC(dir) {
  8.  switch (dir) {
  9.   case "for" :
  10.    this.onEnterFrame = function() {
  11.     if (effectMC._currentframe < 20) {
  12.      effectMC.gotoAndStop(effectMC._currentframe+1);
  13.     } else {
  14.      delete this.onEnterFrame;
  15.     }
  16.    };
  17.    break;
  18.   case "back" :
  19.    this.onEnterFrame = function() {
  20.     if (effectMC._currentframe>1) {
  21.      effectMC.gotoAndStop(effectMC._currentframe-1);
  22.     } else {
  23.      delete this.onEnterFrame;
  24.     }
  25.    };
  26.    break;
  27.  }
  28. }

Download Playing frames in reverse Version 0.1
2. Using some tween class. In this example i am using Caurina Tweener

  1. import caurina.transitions.Tweener;
  2. import caurina.transitions.properties.DisplayShortcuts;
  3. DisplayShortcuts.init();
  4. someButton.onRollOver = function() {
  5.  playMC("for");
  6. };
  7. someButton.onRollOut = function() {
  8.  playMC("back");
  9. };
  10. function playMC(dir) {
  11.  switch (dir) {
  12.   case "for" :
  13.    Tweener.addTween(effectMC,{_frame:20, time:1});
  14.    break;
  15.   case "back" :
  16.    Tweener.addTween(effectMC,{_frame:1, time:1});
  17.    break;
  18.  }
  19. }
This entry was posted in Flash general and tagged , , , . Bookmark the permalink.