How to optimize flash player performance
few guidelines which you need to take case while making flash animation to keep healthy performance of flash player
- When creating animation sequences, use tweened animations, whenever possible. These animations use less file space than a series of keyframes.
- For animation sequences, use movie clips instead of graphic symbols.
- Use symbols, animated or otherwise, for every element that appears more than once.
- Limit the area of change in each keyframe; make the action take place in as small an area as possible.
- Avoid animating bitmap elements; use bitmap images as background or static elements.
- For sound, use MP3, the smallest sound format, whenever possible.
- Group elements as much as possible.
- Do not assign unnecessary frame label property.
- Always use key frame label instead of using frame name if required.
- Always use symbol to mask a layer instead of shape object if possible.
- Try to use less mask layers and utilize to achieve more tasks using single mask layer.
- Remove all unused layer including all guide layer.
- Use layers to separate elements that change during the animation from those that do not. Once the animation scope of an object is finished shift that object to a static layer so that the available pointer of that layer in memory can be used to store other animated or non animated object information. Remember that once you create a layer it takes same memory space as a static variable and work as a pointer in same way as work in c and c++. Flash is weak in removing objects from memory and sending to GC when an object is not in used also weak to assign an object to blank available pointer.
- Use Modify > Curves > Optimize to minimize the number of separate lines that are used to describe shapes.
- Never assign unused linkage property to any symbol.
- Limit the number of special line types, such as dashed, dotted, ragged, and so on. Solid lines require less memory. Lines created with the Pencil tool require less memory than brush strokes.
- Limit the number of fonts and font styles. Use embedded fonts sparingly because they increase file size.
- For Embed Fonts options, select only the characters needed instead of including the entire font.
- Use the Color Mixer (Window > Color Mixer) to match the color palette of the document to a browser-specific palette.- Use gradients sparingly. Filling an area with gradient color requires about 50 bytes more than filling it with solid color.
- Use alpha transparency sparingly because it can slow playback.
- Use the Color menu in the Symbol Property inspector to create many instances of a single symbol in different colors.
- Use runtime filters sparingly. If you can turn it into a raster graphic with those filters, it will likely be a smoother animation. This will be a delicate balance between file size and performance.
- Use motion tweens instead of shape tweens whenever possible.
- Don’t have transparent things on top of transparent things. When transparencies overlap, the processor usage multiplies.
- Keep your frames per second at or below 30. I’ve seen many applications trying to run at 60+ fps. I usually set my applications at around 24.
- Use easing only where you need it because it eats number of CPU usage.
- Learn about cacheAsBitmap. This can speed things up or make them slower, it depends on the context. If you have an animation, keep cacheAsBitmap as false, the cached bitmap will have to be regenerated every time the animation changes, so this isn’t worth it. However, on a vector graphic that doesn’t change within itself, cacheAsBitmap might be a good choice.
- Avoid using transparency (alpha). Flash must check all pixels underneath a transparent shape, which slows rendering down considerably. To hide a clip, set its visible property to false rather than setting the alpha property to 0. That is, graphics render fastest when their alpha is set to 100. Setting the movie clip’s timeline to an empty keyframe (so that the movie clip has no content to show) is usually an even faster option. Sometimes Flash still tries to render invisible clips; move the clip off stage by setting its x and y properties to, say, (-1000, -1000), in addition to setting the visible property to false, so Flash doesn’t try to draw it at all
- Avoid using vectors with gradient fills. Consider using a bitmapped gradient instead.
- Flash’s drawing performance is tied to how many points are drawn per frame. Always optimize shapes after you have drawn them with the Modify Shape submenu, then select either Smooth, Straighten, or Optimize (depending on your graphic) to reduce the number of points required to draw it. Changing strokes to hairlines (or not using strokes at all) can also significantly reduce the number of points needed. You can view the number of points contained in a stroke byclicking on it with the Subselection tool, and you can see the number of points in a shape by clicking on any of its edges.
- Flash’s drawing performance is also tied to the number of pixels that have to change per frame, so avoid large changes. Make your animated content as small as you can get away with; for example, reducing the size of a graphic by 10% in each dimension reduces the area by 19%. The savings really add up when using multiple copies of the symbol, such as for a Space Invaders game.
1 comment