Skip to page content or Skip to Accesskey List.

Work

Main Page Content

Play It Again Sam Flash Timelines In Reverse

Rated 3.35 (Ratings: 2)

Want more?

  • More articles in Code
 
Picture of ideahamster

troy janisch

Member info

User since: 08 Jul 2002

Articles written: 17

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.

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

evolt.org Evolt.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.