Section 10.4. Reversing a Series of Frames


10.4. Reversing a Series of Frames

Reversing a series of frames is a useful effect. A basketball bouncing up and down, a flag waving side to side, or a boomerang advancing and receding: These things are all examples of reversing a single series of frames.

Instead of creating the two complete series of frames by handone showing a ball falling, for example, and another showing the same ball bouncing back upFlash gives you two ways to generate the reverse effect using just one series of frames:

  • You can copy the frame series, paste it, and use Modify Timeline Reverse Frames to reverse the pasted frames. This option is quick and easy, but it doubles your Timeline (and your file size , unless your pasted frames contain nothing but symbols).

  • You can use ActionScript to play a series of frames in reverse. This option's a bit more difficult to create, especially if you're not familiar with programming in ActionScript. But if file size is an issue, it's the way to go, because you have to save only one series of frames in the file.

The following sections demonstrate both of these approaches.

10.4.1. Using Modify Timeline Reverse Frames

When you use Modify Timeline Reverse Frames in conjunction with Flashs copy-and-paste function, you can create the reverse of a series of frames quickly, right on the Timeline.

To create a reversed series of frames using Modify Timeline Reverse Frames:

  1. Click the first frame in the series you want to reverse. Then Shift-click the last frame in the series you want to reverse .

    Flash highlights every frame in the series, from first to last.

  2. Select Edit Timeline Copy Frames. On the Timeline, click the first frame where you want to insert the reversed series of frames .

    Flash highlights the selected frame.

  3. Select Edit Timeline Paste Frames .

    Flash pastes the copied frames onto the Timeline, beginning at the selected frame.

  4. If the pasted frame series isn't highlighted, select it (Figure 10-15, top ).

  5. Choose Modify Timeline Reverse Frames (Figure 10-15, bottom ).

    Flash reverses the frames on the Timeline.

Figure 10-15. Top: You don't have to begin a reverse series directly after the original series, but in most caseswhere you want a seamless transitionyou do. After you paste the series, make sure you select the pasted frames if Flash hasn't done it for you.
Bottom: The Reverse Frames option here appears grayed out if the pasted frame series isn't highlighted.

10.4.2. Using ActionScript

Since there's no function called playBackwards( ) , the most efficient way to reverse a series of frames is to use ActionScript to tell Flash to step backwards through the series one frame at a time. Using this approach, you have only to create (and save to disk) one series of frames, which helps keep the size of your finished animation file as small as possible.


Note: Actions that play animations backward are like potato salad recipes: Everyone seems to have one, and everyone seems to think hers is the only good one. The example in this section represents one way to play a series of frames backwardsnot the way. (The Appendix lists sites that offer additional approaches.)

To reverse a series of frames using ActionScript:

  1. Open the file reverse_no_action.fla, which you can download from the "Missing CD" page .

    (If you like, you can check your work against the already-finished, ActionScript containing example file, reverse.fla, which you can download from the same place.)

    On the Stage, you see an instance of the movie clip symbol rollerball , which contains the word "Flash!" along with a blue-gray ball.

  2. Test the animation by selecting Control Test movie .

    In the test window, the word "Flash!" approaches. At the same time, the ball rolls from left to right.

  3. Click the X in the upper-left corner of the test window to close it and return to your workspace .

    In the next few steps, you'll attach some ActionScript designed to reverse play-back of the movie clip.

  4. On the Stage, click the movie clip instance to select it. Then choose Window Actions .

    The Actions panel appears. In the title bar, you see ActionsMovie Clip.

  5. In the Actions panel, click the Script pane and then type the following ActionScript code :

     onClipEvent (load) {     gotoAndStop(20); } onClipEvent(enterFrame) {     if (_currentframe > 1) {         prevFrame();     } } 

    The above ActionScript code gives Flash two separate instructions:

    As soon as you (meaning Flash) load the movie clip into the frame, go to the last frame in the movie clip (Frame 20) and stop .

    As soon as you (Flash) start to play a frame, play the previous frame. Repeat until you run out of frames (in other words, until all frames have been played , from 20 backwards through to 1 ).

  6. Test the action by choosing Control Test movie .

    In the test window, you see the animation run backwards: The word "Flash!" recedes as the ball rolls from right to left.


Tip: In the ActionScript code above, you can replace 20 with _ totalframes and let Flash figure out the last frame of the movie clip. To see the other movie clip properties you can access (besides _currentframe and _totalframes): In the Actions panel, click "Add a new item to the script" and then click ActionScript 2.0 Classes Movie Movie Clip Properties.



Flash 8
Flash Fox and Bono Bear (Chimps) (Chimps Series)
ISBN: 1901737438
EAN: 2147483647
Year: 2006
Pages: 126
Authors: Tessa Moore

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net