Flash Motion Blur Sprite Source
I’ve finally found some time to clean up my MotionBlurSprite source and make it interchangeable with Flash’s Sprite class.
Features
- Almost completely interchangeable with Sprite class (see caveats).
- Ability to specify blur by angle & distance, or by vector (dx, dy) – the latter is perfect for blurring based on the sprite’s velocity.
- Transforms (rotate, scale etc) affect the filtered sprite, unlike normal Flash filters which are applied after transforms.
Caveats
- No mouse interaction with children, although I’m planning to add child mouse interaction in future.
- Sprite size is limited to Flash’s maximum bitmap size of 2880×2880.
- Need to call blur(), blur2() or update() after changes to graphics or children. It’s best just to call the relevent blur() method on enterFrame after all other updates have been made.
I’d love to know if you use this class in your project – please let me know.
Download MotionBlurSprite_v1.02.zip
Here’s a basic demo of the class with angle and distance controls and the ability to add/remove children and draw to graphics on-the-fly. The standard Flash Sprite is on the left and MotionBlurSprite is on the right. The method calls to add/remove children and draw graphics on both are identical. Thanks to Keith Peters for his awesome little MinimalComps UI components – very handy for things like this.
9 Comments
flanture on August 31st, 2009
great class!
this was actually something I needed earlier when I was coding movie clip shadows, but this is much better and code is clean
thanks for sharing
boxbuilder on April 2nd, 2010
hi! was I hallucinated? Yesterday I saw on your blog a beautiful experiment about 3D motion blur. Is it possible I saw a firefox logo jumping around?
Rob Muller on April 4th, 2010
No, you weren’t hallucinating. Here it is: http://rmd.com.au/archives/flash-radial-spin-zoom-motion-blur
Nolsto on September 27th, 2010
Cool. I wonder if there would be an efficient way to blur the sprite based on its global transform matrix. In effect making the blur scale constant across all sprites, more like a camera aperture.
codeslaw on June 3rd, 2011
This is great, thanks.
Joe on June 12th, 2011
Amazing work, but I can’t figure out how to use it. I have a sprite extending this class, and I’m calling blur2() in an enterFrame function, passing in the correct dx and dy values, but there’s no blur! Could I have a quick example of the implementation?
Rob Muller on June 14th, 2011
Hi Joe,
Sorry – you can’t extend an existing sprite with this class. Think of it more like a container sprite – i.e. you should create an instance of your sprite then add it as a child to an instance of MotionBlurSprite. I’ll update the notes.
Rossie on July 22nd, 2011
Hi Rob!
This is an excellent class! Thank you for sharing!
I fount a small bug, it throwed me a BitmapData argument error, when it occured to the bitmapWith or bitmapHeight property to be less than 1.
I worked it around with a pach at line 129 and 130:
from:
bitmapWidth = (Math.max(tlX, brX) + distance)*2;
bitmapHeight = Math.max(tlY, brY)*2;
to:
bitmapWidth = Math.ceil((Math.max(tlX, brX) + distance)*2);
bitmapHeight = Math.ceil(Math.max(tlY, brY)*2);
I hope this helps others..
Thank you!
Gergely Rossel.


Og2t on August 25th, 2009
At last! ;) It’s great, thanks for sharing Rob.