Something in the air…

Yes, it's close to that time of year again. So here comes the snow...

This requires Flash Player 9.0.124 or greater get it here

The example above (mouse-over to activate) is a Flash 9 example with 1000 blurry snow particles continually falling on random paths. There is also a slightly tweaked version targeting Flash Player 10 (no noticeable performance gains here I'm afraid, just replaced a few Arrays with strictly typed Vectors), and an AS2, Flash 8 version.

The AS2 version can't handle as much snowfall, but the 300 particle example in the source download gives (me) the same processor load as 1000 particles in the AS3 versions (~30% on an old 2GHz pentium, and ~2% on a 2.83GHz Core2Quad)

For speed, I've implemented a linked-list for the particles and there are no transformations on them in motion, except for x/y translation. I'm also pre-drawing and blurring each particle bitmap when the class initialises, then re-cycling them when they leave the snow bounds.

The compiled size of the Snow class is about 4KB for the AS3 versions, and 5KB for the AS2. I've embedded the winter trees image in the examples, so the end file sizes are about 36KB larger than they would be with just the snow.

Feel free to use the code as you want, any feedback or details of how and where you've used it would be great :)

Snow (includes all source files and the example above)