Jumpy MovieClips, PixelSnapping and filters, the hack

The jumpy MovieClip.. is caused by Flash moving the content of the movieclip pixel by pixel. This, although Flash is capable of subpixel operations via it’s AntiAliasing engine, in some circumstances it will discard them. Most of this circumstances are related to speed optimizations and/or bugs on the Flash player. The first thing you need to do if you find that the animation of the movieclip is not smooth, is to disable cacheAsBitmap. cacheAsBitmap inherently disables sub pixel operations thus, if set to true, the movieclips (or any other displayobject for that matter) will have a sloppy animation.

PixelSnapping.. If you create/load the content of the display object at runtime, ie load a bitmap or create one via a bitmapdata.draw AND want smooth animation you will have to specify pixelsnapping. PixelSnapping is a property of the Bitmap class, that can have 3 values, NEVER,ALWAYS,AUTO. By default it’s set to AUTO which causes some snapping to occur in some circumstances. Set this to NEVER.

The filters.. As I stated earlier, some cases in which pixelsnapping always enabled are due to some optimizations required. The use of filters is one of these cases. Basically whenever you add a filter to a displayobject the cacheAsBitmap property will always be overriden to true. There’s no way that I know of to over-override this and probably even if there would be, I suspect the end results would be less than acceptable.

the hack.. If you still decide that you want to use filters and also must have smooth animation, there’s at least a way to deal with it. This consists of drawing the movieclip with the filters on into a bitmapdata, creating a bitmap with pixelsnapping set to never with this bitmapdata and using it instead of the original movieclip. This works quite well with movieclips that are static (sprites) since because of rendering the filter also, the renderer has one less thing to do (even if this is cached at runtime).

of course, if someone wants a snippet of the code, just let me know,

dw.

Tags: ,

One Response to “Jumpy MovieClips, PixelSnapping and filters, the hack”

  1. teejay says:

    hello, thanks a bunch!
    this post really kept me mentally healthy, while strugling to move large bitmap around scene slow & seamlesly.. especialy the part hack :o)

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word