Skip to page content or skip to Accesskey List.
Search evolt.org
evolt.org login: or register

Work

Main Page Content

Play it Again, Sam: FLASH Timelines in Reverse

Rated 3.35 (Ratings: 2) (Add your rating)

Log in to add a comment
(4 comments so far)

Want more?

 
Picture of ideahamster

troy janisch

Member info | Full bio

User since: July 08, 2002

Last login: September 07, 2005

Articles written: 15

Sooner or later, every Flash developer is surprised to learn how difficult it is to play a movie backwards in FLASH. When this happens, instinct sends them to one of more than 20 different methods described in online tutorials.

Most methods for playing a Flash movie backwards require the programmer to embed a movieclip containing actionscript that monitors the _root level move and determines when it needs to play backwards and where to stop.

This brief tutorial presents an alternative approach that can be implemented and scaled to virtually any Flash project. The tutorial is brief because only a few lines of code are required. In fact, It's as easy as 1-2-3.

1. Call to Action

Create an actionscript layer that extends the full length of your movie. In that layer, include the following actionscript:

function Movement() {
  if (_root._currentframe > _root.mytarget){
    prevFrame();
  }else if (_root._currentframe < _root.mytarget){
    nextFrame();
  }else{
    stop();
  }
}
this.onEnterFrame= Movement;

2. onPress your buttons

Attach code to your buttons that tells the script the frame to stop on when clicked:

on(Press){
  _root.mytarget=59;
}

Using the code above, the movie will play either backwards or forwards to the desired destination.

3. Avoid all Stops

As written, the code eliminates the need to have stop() commands throughout the movie since you can indicate all stopping points within navigation. Movieclips can still be used on stopped frames to create animations as desired.

Over time, you'll find this method of moving backwards and forwards in the timeline to be very adaptable. Enjoy!

Troy Janisch is president and founder of Icon Interactive™, an industry leader helping companies integrate Internet and other Interactive media into sales channels, marketing strategies, and overall branding. He can be contacted by email at tjanisch@iconinteractive.com.

Sorry, thats a bit CPU intensive for me

Submitted by Angstrom on July 23, 2004 - 16:06.

Flash is a cpu hog already, don't encourage it! this.onEnterFrame= Movement; will be called repeatedly when we only want it to run when animation is required. Also your function only deals with _root animations so I have re-written it to work for a targeted object, the function now has a ' targ_mc' parameter where you can specify the clip you want to animate ( for this example it remains _root).

function movement(destination, targ_mc) { targ_mc.onEnterFrame = function() { if (targ_mc._currentframe>destination) { targ_mc.prevFrame(); } else if (targ_mc._currentframe

In the button(s) we now put this code to target the _root animation

on (release) {
movement(45,_root);	
}

Obviously that button will take _root to frame 45. But If we wanted a clip called "car" on the root to play to frame 10, we would use :

movement(45,_root.car);

login or register to post comments

damn, that mangled my code block

Submitted by Angstrom on July 23, 2004 - 16:10.

here's that function again, I dont seem to have grasped Evolts code commenting. Ifully expect this one to look terrible also
function movement(destination, targ_mc) {
	targ_mc.onEnterFrame = function() {
		if (targ_mc._currentframe>destination) {
			targ_mc.prevFrame();
		} else if (targ_mc._currentframe  
  

login or register to post comments

reverse timeline

Submitted by digiman on January 9, 2009 - 13:10.

hello, code works well.. and thanks for that Problem is, i have an ease in the motion tween.. so it plays fine forward.. but when playing backwards, instead of moving from slow to fast it moves from fast to slow.. and i cant really remove the ease.. any ideas?

login or register to post comments

The access keys for this page are: ALT (Control on a Mac) plus:

evolt.orgEvolt.org is an all-volunteer resource for web developers made up of a discussion list, a browser archive, and member-submitted articles. This article is the property of its author, please do not redistribute or use elsewhere without checking with the author.