How to Play Reverse Frames Flash on AS3

Reversing frames with Flash ActionScript 3 (AS3) code comes in handy when creating Flash movies. For example, by reversing the frame sequence for a sunset animation you can quickly create a sunrise, eliminating the need to create a sunrise animation from scratch. There is no reverse frame command in AS3. As a result, playing frames in reverse with AS3 requires that you write AS3 code that will force the animation to start at the last frame and step one frame back every time a frame event occurs.

Things You'll Need

  • Adobe Flash Professional: CS3, CS4 or CS5 Versions
Show More

Instructions

    • 1

      Start the Flash program and select "Flash File(ActionScript 3.0)" from the splash screen to allow AS3 code to be used to build your movie.

    • 2

      Click the "Timeline" option from the "Window" menu to display the timeline. Press the "F6" key on your keyboard to insert a keyframe on the timeline. Continually press the "F6" key until 30 keyframes have been inserted on the timeline. Tiny circles will be placed in each frame to signify that the frame is a blank keyframe.

    • 3

      Position your mouse cursor over "Frame 1" in the timeline and click your left mouse button to select it. Press the "R" key on your keyboard to activate the rectangle drawing tool. Position your mouse cursor over the stage, then click and drag your mouse to draw a rectangle. Release the left mouse button to set the size of the rectangle. Click "Frame 2" on the timeline and draw another rectangle, but at a different position on the stage. Continue drawing rectangles on each frame in different positions until you have reached frame 20.

    • 4

      Position your mouse cursor over "Frame 1," then click your left mouse button to select Frame 1. Press the "F9" key on your keyboard to open the Actions editor and write the reverse frames AS3 code in Frame 1.

    • 5

      Position your mouse cursor on the first line of the Actions editor. Click your mouse button and type in the code below. This will instruct Flash to go to the end of the movie (frame 30) and display the frame preceding the last frame displayed (starting at 30) every time a new frame is displayed (at the frame rate in frames per second specified in the "fps" text box in the Timeline panel).

      gotoAndStop(30);

      addEventListener(Event.ENTER_FRAME, reverse);

      function reverse(reverseevent:Event):void

      {

      prevFrame();

      }

Learnify Hub © www.0685.com All Rights Reserved