Skip to navigation

malevolent design weblog

This blog is now defunct, but you can find more stuff over at my personal site

Faster Flash

Even quite simple Flash games/animations can be CPU hogs, but there are many ways to squeeze out more performance. Here’s a summary of what I’ve learned:

The web page
If the rest of the page features other Flash movies or large animated GIFs then they’ll be competing for processor time, so always present complex games on simple pages. Don’t embed with wmode set to transparent unless you really need it. Flash 10 introduces new modes, but it sounds like they’ll only improve performance in certain circumstances.
Dimensions
I reckon some games are actually too small (designed to fit into cramped page layouts), but obviously a smaller game will render faster so it’s a factor to consider.
Frame rate
Don’t be too ambitious, around 20 is usually sensible.
Rendering quality
Setting _quality to medium means anti-aliasing uses a 2x2 grid instead of 4x4. This can be significantly faster without looking significantly worse, so I use it for most games. If text uses ‘Anti-alias for readability’ it’ll stay sharp and legible.
Optimising graphics
Carefully reducing the complexity of shapes, either manually or with Modify > Shape > Optimize, can be worthwhile. Any large static vector graphics (e.g. a background) can be replaced with bitmaps (use File > Export > Export Image to create them).
Bitmap caching (v8+)
Try ticking the ‘Use runtime bitmap caching’ property (or set cacheAsBitmap to true in code) for complex movie clips that don’t change/scale/rotate (movement is fine). After rendering once, the plugin will retain the bitmap data for subsequent frames, using more memory but less CPU time. If the movie clip doesn’t need transparency you can also set its opaqueBackground property to a colour (in hex, e.g. 0xFF6600) to further improve performance.
Faster full-screen (v9+)
Using fullScreenSourceRect you can specify the area that’ll be rendered then hardware-rescaled to fill the screen. This is great for zooming videos or games without them struggling on large displays.
Coding
Check for inefficient areas such as loops that may not scale well, excessive collision detection checks, things that could be stored instead of regenerated each frame, etc.

Comments


Comments are now closed for this entry.