Matt Sweetman

Latest articles

Flash and Canvas

Snowfall screenshot

Over the holidays I gave myself a break from Actionscript and took a look at the HTML5 Canvas object. I've been keen to see what can be done with the new HTML5 elements, especially given the discussion about Javascript becoming a replacement for Flash. I decided to port over an old Actionscript experiment to see how the two technologies performed alongside each other.

You'll need a modern browser to view the canvas version (eg: Firefox, Chrome, Safari). They seem to vary wildly in performance so if one browser's too slow try taking a look in another.

After some tweaking I've managed to get them looking almost identical. The Canvas object was surprisingly easy to work with and not too dissimilar to Flash's BitmapData. The biggest difference lies in performance - right now Flash is a lot faster, and can handle more than double the elements of the Canvas version before dropping frames. Canvas (and perhaps Javascript) seems prone to slowdown, hiccups and frequent speed changes. I'm sure it'll get better in time, but right now Flash seems the better choice if performance is a concern.

The other problem is that Canvas doesn't seem like a particularly good animation tool. I think an abstracted library would be required to get the most out of it, something that provides a similar nested sprite system to Flash.