Skip to main content
rafa@mediatech
Inspiring
October 21, 2008
Question

Using AS3 to play a set of frames I want and then stop

  • October 21, 2008
  • 10 replies
  • 2886 views
Hi everyone:
I am helping a friend with a project. I have a button that when clicked on, it enlarges and shows content inside the button. Now, there is more content inside this button that when clicked on, enlarges and shows more content. I have all that working fine.
How can I create a "back" button that will play the same frames that I created my animation in, but play them in reverse to get the same animation but back. Is this the correct way of doing it, or do I need to create animated transitions for the reverse state as well.?

Rafael.
This topic has been closed for replies.

10 replies

kglad
Community Expert
Community Expert
January 11, 2009
define a function that assigns the currentFrame as a none local variable and initiate the above ENTER_FRAME loop checking if the difference between the currentFrame and the variable is 9.
kglad
Community Expert
Community Expert
January 10, 2009
sure. you can play anytime from any frame to any other frame (forwards or backwards) at any fps (your computer can handle).

to play a timeline backwards from the current frame to frame N at the default fps, change the 1 in the code above to N.
Participant
January 10, 2009
How could I move back a certain amount of frames? Let's say I want to reverse the timeline 9 frames backward? What can I write to do this?
Participant
January 10, 2009
This is a great great great thread to have the movieclip play in reverse. However, I was also wondering if it is possible to make the movieclip move back go back a certain amount of frames, and not back to the very beginning of the timeline.
kglad
Community Expert
Community Expert
October 21, 2008
direct the main timeline to whatever frame so that movieclip exists (after the render event fires) and then execute the code that plays the movieclip's timeline in reverse.
rafa@mediatech
Inspiring
October 21, 2008
Right, but the object existed...and still exists on frames 2-9. I need to some how tell it to play those frame in reverse when the back button is hit and then stop.
thanks,
Rafael
kglad
Community Expert
Community Expert
October 21, 2008
you can't expect code for a non-existent object to work. you must wait until your object exists before executing that code.
rafa@mediatech
Inspiring
October 21, 2008
Ok, so I take it that it looks for the movie clip to be present at the moment and then plays reverse until the movie clip is done.

The problem I have is...

NAV:
button exist on frame 1. When user clicks the button, I replace the button with the movie clip on the next frame, flash plays the movie clip from frame 2 to frame 9. I have a stop command on frame 10 which is a button identical to the last frame of the movie clip (so that it is a seamless transition). If I add the "Back" button on frame 10, the movie clip doesnt exist here any more...would this be an issue?

Rafael.
kglad
Community Expert
Community Expert
October 21, 2008
you need to use the name of your movieclip. that's all you need to change.

the enterframe loop repeatedly calls function ff(). function ff() plays the previous frame of yourmovieclip each time its called. when yourmovieclip reaches frame 1, the enterframe loop is removed.
rafa@mediatech
Inspiring
October 21, 2008
Hi kglad:
Thank you for replying so promptly. This is great...I wont be able to test until tonight. Can you explain to me a little how it works? I understand I am telling it to to this command on my back button "click" event, and I believe I need to replace "yourmovieclip" with the name of the movie clip I want it to play backwards (correct?). Now, do I need to tell it the expand of the movie clip, like from frame 20 to frame 10?

I apologize, I am fairly new to flash, and learning AS3 really fast so that I can be help my friend.

Rafael.
kglad
Community Expert
Community Expert
October 21, 2008
you can play a timeline in reverse using:

Participant
February 16, 2009
hi.
i found this while preparing to start coding a new site. I used placeholder movieclips until I received all the final assets.
this code worked great when I had shorter test movieclips. Now I have a 75 frame, embedded .flv that I would like it to reverse and it chugs badly. The project is set to 30fps to match the animation (embedded .flv).
I've encoded it at 1500kbps, which I know is ridiculous, but they're highly texturized 3d animations. and they play fine going forward, so I don't know why they shouldn't in reverse. Any thoughts on how to increase the efficiency?
thanks for your help