Skip to main content
Known Participant
May 27, 2009
Answered

Making the main stage timeline play in reverse.

  • May 27, 2009
  • 1 reply
  • 1578 views

Hey all thanks for looking. I figured out how to do this with movie clips but I can't seem to get it right with the main stage. Can anyone tell me a simple methood of telling the stage to continue playing in reverse, after a button is clicked, until it reaches a keyframe that will tell it to stop? I'm trying to make it so buttons will tell the stage to play a transition from beginning to end and then have it play in reverse when the "back" button is pressed. I'm currently searching online to find an answer but I haven't had any luck yet. Thanks for the help!

This topic has been closed for replies.
Correct answer kglad

This is good. Thanks! Can you tell me how to reference the root timeline from inside a MC. I thought I could do it like this:

ex.  root.gotoAndPlay(25);


:

MovieClip(root).gotoAndPlay(25);

playF(MovieClip(root),MovieClip(root).currentFrame,1);   //  play the root from its current frame to frame 1.

1 reply

May 27, 2009

Say back_btn is your reverse button. now go through the code below,

var speed:Number = 10;
//speed can be calculated using fps
var frameNoToStopOn = 5;
var t:Timer = new Timer(speed)

back_btn.addEventListener(MouseEvent.CLICK, playReverse);

function playReverse(evnt:MouseEvent)
{
t.start();
t.addEventListener(TimerEvent.TIMER, goBack);
}


function goBack(evnt:TimerEvent)
{
if(currentFrame == frameNoToStopOn)
{
  t.stop();
  t.removeEventListener(TimerEvent.TIMER, goBack);
  return;
}
else
{
  gotoAndStop(currentFrame -1);
}
}

Known Participant
May 27, 2009

Thanks for the reply! Right now it's not working for me yet but I'm still analysizing the script to make sure I understand how I set up my stage and timeline. If I have anymore trouble with it I will let you know.