When working with tweens in Flash we often create custom time-line based animations for various elements of the project. These time-line animations can sometimes need to be played in reverse by the frame count and not by a time duration. If one utilizes the TweenLite or TweenMax Tweening Framework this task can easily be completed by use of the frameLabel and useFrames parameters.

The frameLabel property defines the name of the frame that the movie clip should be tweened to enabling us to tween a movie clip both forward and backwards.

TweenLite.to( movieclip, 1.5, { frameLabel:"intro" } );

The above example will tween to the labeled frame over 1.5 seconds. If instead we want our animation to play over 60 frames we would use the useFrames property which treats the second parameter as the number of frames and not number of seconds.

TweenLite.to( movieclip, 60, {frameLabel:"intro", useFrames:true} );

Lastly we may want to have the animation play back to a previous label using the exact animation duration that it was created with. This task although more complicated can be accomplished the first step is to set the ease type to Linear.easeNone which will make the animation play uniformly. The second step is to know the exact number of frames between the current frame of the movie clip and the desired frameLabel. Flash does not provide an interface for obtaining the frame number of a labeled frame and instead you will have to create your own utility and formulas for determining the duration. A simple method would be to have an associated array or dictionary of the frame labels with their corresponding frame number that you can then get the difference of the current frame and that value.

TweenLite.to( movieclip, frameDiff, {frameLabel:"intro", useFrames:true, ease:Linear.easeNone} );
, , , , ,

When developing in Flash we often find ourselves developing straight code based animations as well as time-line animations.  And when creating the time-line based animations we often find ourselves wishing to play the animation in reverse in certain occasions.

Unfortunately Flash does not have reverse capability built in, Yes it has the prevFrame() method which could be used with the onEnterFrame() event to play in reverse but this method is not as straightforward as a developer would wish and is easily prone to bugs do to the amount of state checking.

Luckily for us developers that use a Tweening library such as TweenLite and TweenMax (available at greensock.com ) provides us an easy to use interface for playing our animations forward and reverse to any desired location. To accomplish this we use the Frame and FrameLabel plugins. These plugins allow us to tween to a desired frame or labeled frame respectively.

A quick example of how to use is:

TweenLite.to( moviclip, 1, { frame:40 } );
TweenLite.to( movieclip, 1.5, { frameLabel:"intro" } );
, , ,