Skip to Content
Flash 8 Cookbook
book

Flash 8 Cookbook

by Joey Lott
April 2006
Beginner
544 pages
14h 51m
English
O'Reilly Media, Inc.
Content preview from Flash 8 Cookbook

10.6. Playing the Timeline Backward

Problem

You want to play the timeline backward.

Solution

Use the prevFrame( ) action within an onEnterFrame( ) event handler method in combination with bounds checking.

Discussion

By default, each movie clip timeline (including the main timeline) plays back in a forward direction. And Flash does not have a built-in function or method that can automatically instruct a timeline to play in reverse. However, with just a bit of ActionScript code, you can cause a timeline to play backward.

The basic idea is as follows: at the frame rate of the movie, tell Flash to move the playhead back one frame. Instructing the playhead to move back one frame is fairly simple. The only challenge is to then tell Flash to call the prevFrame( ) method at the frame rate of the movie. That too is fairly simple, because there is a built-in event handler method named onEnterFrame( ) that gets called at the frame rate of the movie. Therefore, in order to instruct a timeline to play in reverse, you should define the onEnterFrame( ) event handler for the movie clip such that it calls prevFrame( ). The following example instructs a movie clip named mAnimation to play backward:

	mAnimation.onEnterFrame = function():Void {
	  this.prevFrame();
	};

As you can see, you can define an onEnterFrame( ) event handler method, just as with the other already-familiar event handler methods such as onPress( ) and onRelease( ). Also notice that within the event handler method, you can refer to the movie ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Flash® CS4 for Dummies®

Flash® CS4 for Dummies®

Ellen Finkelstein, Gurdy Leete

Publisher Resources

ISBN: 0596102402Catalog PageErrata