Wednesday 2 June 2010

Smokescreen Converts Flash to JavaScript On the Fly

Smokescreen Converts Flash to JavaScript On  the FlyNow this is interesting. Smokescreen, written by Chris Smoak, is a "Flash player written in JavaScript" that takes Flash objects and converts them to JavaScript in real time.

What's that mean? Well, it means it can allow Flash to work where it isn't supported, such as on the iPad. Here's how it works:

It runs entirely in the browser, reads in SWF binaries, unzips them (in native JS), extracts images and embedded audio and turns them in to base64 encoded data:uris, then stitches the vector graphics back together as animated SVG.

It's impressive stuff! You can check out a Homestar Runner demo on their site, and it runs beautifully.

One problem, however, is that the whole thing is pretty hefty, clocking in at over 8,000 lines of JavaScript and 175KB, which may make performance on phones and iPads difficult. But the code is set to be open sourced in the near future, so it should be tweaked to run like butter on mobile devices with a little luck. Awesome stuff. [Smokescreen via Simon Willison via Jim Ray via Marco.org]



Source:
Smokescreen Converts Flash to JavaScript On the Fly