Filters and swf file performance, Bitmap caching and swf file performance – Adobe Flash Professional CC 2014 v.13.0 User Manual
Page 858

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 faster than it does at 12 fps, so the total
duration (in seconds) is shorter. Therefore, to make a 5-second animation using a higher frame rate, you must add additional frames to fill those
five seconds than at a lower frame rate (and thus, raises the total file size of your animation). A 5-second animation at 24 fps typically has a higher
file size than a 5-second animation at 12 fps.
Note: When you use an onEnterFrame event handler to create scripted animations, the animation runs at the document's frame rate, similar to if
you created a motion tween on a timeline. An alternative to the onEnterFrame event handler is setInterval (see ActionScript 2.0 Language
Reference). Instead of depending on 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, which helps reduce the strain on the end-user's
processor. High frame rates (more than 30 to 40 fps) put a lot of stress on processors, and do not change the appearance of the animation much
or at all at runtime.
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.
Filters and SWF file performance
If you use too many filters in an application, you can use large amounts of memory and cause Flash Player performance to suffer. Because a
movie clip with filters attached has two bitmaps that are both 32-bit, these bitmaps can cause your application to use a significant amount of
memory if you use many bitmaps. The computer's operating system might generate an out-of-memory error. On a modern computer, out-of-
memory errors should be rare, unless you are using filter effects extensively in an application (for example, you have thousands of bitmaps on the
Stage).
However, if you do encounter an out-of-memory error, the following occurs:
The filters array is ignored.
The movie clip is drawn using the regular vector renderer.
No bitmaps are cached for the movie clip.
After an out-of-memory error occurs, a movie clip never attempts to use a filters array or a bitmap cache. Another factor that affects player
performance is the value that you use for the quality parameter for each filter that you apply. Higher values require more CPU and memory
for the effect to render, whereas setting the quality parameter to a lower value requires fewer computer resources. Avoid using an excessive
number of filters, and use a lower quality setting when possible.
Important: If a 100 pixel by 100 pixel object is zoomed in once, it uses four times the memory since the content's dimensions are now 200
pixels by 200 pixels. If you zoom another two times, the shape is drawn as an 800 pixel by 800 pixel object which uses 64 times the memory
as the original 100 pixel by 100 pixel object. Whenever you use filters in a SWF file, disable the zoom menu options from the SWF file's
context menu.
You can encounter errors if you use invalid parameter types. Some filter parameters also have a particular valid range. If you set a value
that's outside of the valid range, the value changes to a valid value that's within the range. For example, quality should be a value from 1 to 3
for a standard operation, and can only be set to 0 to 15. Anything higher than 15 is set to 15.
Some constructors have restrictions on the length of arrays required as input parameters. If a convolution filter or color matrix filter is created
with an invalid array (not the right size), the constructor fails and the filter is not created successfully. If the filter object is then used as an
entry on a movie clip's filters array, it is ignored.
When using a blur filter, using values for blurX and blurY that are powers of 2 (such as 2, 4, 8, 16, and 32) can be computed faster and
give a 20% to 30% performance improvement.
Bitmap caching and SWF file performance
Bitmap caching helps you enhance the performance of nonchanging movie clips in your applications. When you set the MovieClip.cacheAsBitmap
or Button.cacheAsBitmap property to true, Flash Player caches an internal bitmap representation of the movie clip or button instance. This can
improve performance for movie clips that contain complex vector content. All of the vector data for a movie clip that has a cached bitmap is drawn
to the bitmap, instead of to the main Stage.
Note: The bitmap is copied to the main Stage as unstretched, unrotated pixels snapped to the nearest pixel boundaries. Pixels are mapped one-
to-one with the parent object. If the bounds of the bitmap change, the bitmap is re-created instead of being stretched.
For detailed information on caching button or movie clip instances see the following topics:
About caching and scrolling movie clips with ActionScript in
Caching a movie clip in
Use the cacheAsBitmap property with movie clips with mostly static content and that do not scale and rotate frequently. With such movie
clips, using the cacheAsBitmap property can lead to performance improvements when the movie clip is translated (when its x and y position
is changed).
851