Most Read This Week
Flex Top Links You Must Click On !
Flash Animation Learning Guide (Part I)
Flash Basic 8 and Flash Professional 8 offer several ways to include animation and special effects in your document
Jan. 8, 2006 03:30 PM
Flash Basic 8 and Flash Professional 8 offer several ways to include animation and special effects in your document. For example, you can create tweened animations using the Timeline and Flash workspace, automated Timeline effects (by making selections in a dialog box), or ActionScript code.
To create tweened animations, you create starting and ending frames and let Flash create the animation for the frames in between. Flash varies the object's size, rotation, color, or other attributes between the starting and ending keyframes to create the appearance of movement. You can also create animation by changing the contents of successive frames in the Timeline. You can make an object move across the Stage, increase or decrease its size, change its color or shape, rotate it, and even fade in or out. Changes can occur independently of, or in concert with, other changes. For example, you can make an object rotate and fade in as it moves across the Stage. In frame-by-frame animation, you create the image in every frame.
You have several options when creating tweened animations. You can create traditional frame-by-frame animations (see the section, Creating Frame-by-Frame Animations, http://macromedia.com/devnet/flash/articles/animation_guide_09.html), motion tweens (see Creating Motion Tweens, http://macromedia.com/devnet/flash/articles/animation_guide_05.html), or shape tweens (see Creating Shape Tweens, http://macromedia.com/devnet/flash/articles/animation_guide_07.html).
Timeline effects include animated vector effects such as blur, expand, and explode. This feature makes it easy to animate an object: you can simply select the object and then select an effect and specify its parameters. With Timeline effects, you can accomplish in a few easy steps a previously time-consuming task that required more advanced knowledge of animation.
You can also create an animation by writing ActionScript code, which is sometimes called scripted animation. There are different ways you can script animation: you can write ActionScript to handle all aspects of the animation or you can use prebuilt classes and simpler code to create an animation. Using prebuilt classes makes animating with code quite easy.
Using code to create animations and effects often reduces the file size of your finished application, and can also improve the performance and consistency of the animation itself. At times, ActionScript-based animations might even reduce your workload: code can be faster to write, and it's easy to apply to many instances at once or reuse in other applications. The following sections introduce you to scripted animation fundamentals, animation using the Tween and TransitionManager classes, and integrating animation with both the Drawing API and filter classes.
Note: For more information on filter effects, see the Flash Graphic Effects Learning Guide (http://macromedia.com/devnet/flash/articles/graphic_effects_guide.html).
About Frame Rate and Animation
You need to think about frame rate when working with animations because it can affect the performance of your SWF file and the computer that plays it. Setting a frame rate too high can lead to processor problems, especially when you use many assets or use ActionScript to create your animation. However, you also need to consider the frame rate setting because it affects how smoothly your animation plays.
For example, an animation set to 12 frames per second (fps) in the Property inspector plays 12 frames each second. If the document's frame rate is set to 24 fps, the animation appears to animate more smoothly than if it ran at 12 fps. However, your animation at 24 fps also plays much faster than it does at 12 fps, so the total duration (in seconds) is shorter. Therefore, if you need to make a five-second animation using a higher frame rate, it means you need to insert additional frames to fill those five seconds than at a lower frame rate‹which raises the total file size of your animation. A five-second animation at 24 fps typically has a higher file size than a five-second animation at 12 fps, depending on your assets and how you are animating the content.
Tip: Because you specify only one frame rate for the entire Flash document, it's a good idea to set this rate before you begin creating the animation.
Note: When you use an onEnterFrame event handler to create scripted animations, the animation runs at the document's frame rate, as if you created a motion tween on a timeline. An alternative to the onEnterFrame event handler is setInterval. Instead of depending on the frame rate, you call functions at a specified interval. Like onEnterFrame, the more frequently you use setInterval to call a function, the more resource-intensive the animation is on your processor.
Use the lowest possible frame rate that makes your animation appear to play smoothly at runtime because it will help reduce the strain on the end-user's processor. Try not to use a frame rate that's more than 3040 fps; high frame rates put a lot of stress on processors. Also, do not change the appearance of the animation much, or at all, at runtime.
Finally, especially if you're working with Timeline-based animations, select a frame rate for your animation as early as possible in the development process. When you test the SWF file, check the duration and the SWF file size of your animation. The frame rate greatly affects the speed of the animation.
Creating Keyframes for Animations
Keyframes are indicated in the Timeline: A keyframe with content on it is represented by a solid circle; an empty keyframe is represented by an empty circle within the frame. Subsequent frames that you add to the same layer have the same content as the keyframe.
To create a keyframe, do one of the following:
Motion tweens are indicated by a black dot at the beginning keyframe; intermediate tweened frames have a black arrow with a light blue background.
Shape tweens are indicated by a black dot at the beginning keyframe; intermediate frames have a black arrow with a light green background.
A dashed line indicates that the tween is broken or incomplete, such as when the final keyframe is missing.
A single keyframe is indicated by a black dot. Light gray frames after a single keyframe contain the same content with no changes and show a black line with a hollow rectangle at the last frame of the span.
A small a indicates that the frame has frame scripts assigned to it with the Actions panel.
A series of keyframes with a light gray background might indicate a frame-by-frame animation.
A hollow circle represents a blank keyframe, and white frames represent frames with no content. This frame begins a section with no content on the layer. For example, if you have an instance that blinks on a layer, you might insert blank keyframes where you do not want the instance to appear.
Reader Feedback: Page 1 of 1
Featured White Papers
Latest Flex Stories & Posts
Subscribe to the World's Most Powerful Newsletters
Developer Links You Must Click On !