Introducing Gordon: the Flash Player Written in JavaScript

Gordon - the Flash JavaScript playerJavaScript has been used for a number of unusual projects in the past few years. We’ve had NES emulators, Spectrum emulators, and even Amiga emulators. But a Flash player?… What’s the point of emulating a browser plugin within a browser?

It’s not as bizarre as it sounds. There is one very good reason for a JavaScript-based player: the Flash plugin isn’t available on all platforms. Most notably, you can’t run Flash on a iPhone or Apple’s new iPad.

Gordon” is a cleverly-named project by Tobias Schneider which hopes to rectify the situation. It translates Flash SWF files to Scalable Vector Graphics which are supported on the iPhone. The project runs on most modern browsers with the exception of Internet Explorer (which doesn’t offer native SVG support … yet).

Gordon currently supports the SWF 1.0 format and SWF 2.0 is in development. There are several demonstrations available and, although they’re simple, they work well and show the potential.

Of course, all this work might be in vain if the real Flash plugin appears on the iPhone. But that seems fairly unlikely — Steve Jobs has little regard for Flash and states that it runs too slowly on the device. It’s also a competitor to the standard iPhone/iPad applications platform.

However, Gordon has been tested on the iPhone and it runs fast enough even though it’s built on interpreted JavaScript code. If the project becomes a success, the human centipede rapidshare, there will be nothing Apple can do to prevent Flash running on the device. Could that provide developers with another reason to desert iPhone applications?

Have you tried Gordon? Could it ever be a viable alternative to the Flash plugin on unsupported browsers? Should Adobe hire the developer immediately?!

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

  • http://www.dangrossman.info Dan Grossman

    Oh come on. It can translate some vector primitives to SVG. It’s not a Flash runtime. And the #1 reason people want Flash on their iPads is multimedia. Hulu, streaming music. You can’t turn streaming video and audio into a 2D vector graphic.

  • http://www.optimalworks.net/ Craig Buckler

    There are already alternative video formats which can be used on the iPhone so there’s little reason for Gordon to offer it. (That said, there’s no reason why Gordon couldn’t implement some sort of automated video switching for the target device?)

    So, yes, Gordon’s more for SWF animations. I’m sure that will interest many Flash developers who want to target the Apple iPhone or iPad.

  • http://www.dangrossman.info Dan Grossman

    I’m tired and cranky at the moment, but with this having little hope of ever doing more than translating vector graphics, I don’t see it ever being used beyond a toy to play audio-less cartoons without a plugin. It doesn’t do multimedia, it doesn’t do external assets, it’s not an ActionScript interpreter so you can’t write anything more than scripted animations and buttons (supposedly, that demo’s been a 404 for over a month) with it. If a Flash developer has an application worth targeting the iPad with, it’s not going to be moving some sprites around a stage. You’re not gonna see Facebook polish this up and drop it in their site so you can play FarmVille on an iPhone, it can’t do 95% of what a Flash app like that does.

  • Matt B.

    Craig thanks for the heads up on this I’ll have to check it out and play with it a bit.

    As for getting your jabs in on Flash for the iPhone there are a few different arguments for that all are valid and many leave it to Adobe to do something about it. It feels like you just wanted to take a cheap shot and in doing it offer not relevance to the article.

    Fact is Flash is buggy on OS X and Linux, Apple has stated that the majority of their crash reports involve the Flash player. As for Flash as an alternative development tool for iPhone there are already Flash coded apps on the iPhone, look at Adobes site, CS5 will even have more tools for this. Not to mention HTML5 and Javascript are both development platforms on the iPhone as well given tools like PhoneGap and Titanium.

    Apple is merely preventing the buggy 32bit flash player, and with Google making a big push on HTML5 I would not think it too long before YouTube begins to experiment with it as well.

  • http://www.optimalworks.net/ Craig Buckler

    I agree that Adobe often produces some shocking software but, to me, Apple appear to be making a few too many excuses. They have good commercial reasons not to offer Flash but won’t say that.

    For the record, I’m not a Flash developer and I do think many people use it for frivolous effects which could be achieved using more appropriate standards-based technologies (HTML, CSS, JS, SVG etc). However, it’s a widely available plugin and does have its uses.

    There would be uproar if Microsoft prevented Flash running on Windows or IE (which would give Silverlight a boost). Should Apple be able to restrict what software is written for and used on their OS?

  • EastCoast

    I’ve had a quick play with this but it’s a long way off usable currently. You can’t script anything, use transparency or use movieclips, and the only way to add a link or button would seem to be use a copy of future splash animator (flash 1) if you can find one. It can animate basic vector shapes and pretty much nothing else.

  • http://www.magain.com/ Matthew Magain

    There would be uproar if Microsoft prevented Flash running on Windows or IE (which would give Silverlight a boost). Should Apple be able to restrict what software is written for and used on their OS?

    Too true Craig. How popular do Apple need to become before this question is asked by the Justice dept?

  • http://www.dangrossman.info Dan Grossman

    Surprising. How popular does SitePoint need to become before your government should sweep in and demand you cover .NET/Silverlight as often as you cover Adobe tech in your articles? Or that you must create Bing and Yahoo! forums since you have a Google forum? Apple has single digit market share in any market you put it in… you are seriously asking some government come in and tell them how they’re allowed to run their business?

  • http://www.sitepoint.com AlexW

    I think it’s pretty good for a first take.

    The fact is there are a lot of simple restaurant and shop sites out there that are done in Flash templates. Yes, that’s dumb but they probably don’t know any better.

    But if I just want to grab an address or phone number from their website with my iPhone I’m stuffed. If I could pass that SWF to an server app that broke it down to something I could at least read and navigate, I’d be happy.

  • Slamm

    Hey Matt B the time is now http://www.youtube.com/html5

  • W2ttsy

    Apple has single digit market share in any market you put it in… you are seriously asking some government come in and tell them how they’re allowed to run their business?

    Have you been hiding under a rock since 1999? Apple has not only come into the double digit market share with their computers, but they basically own digital music players, have exceeded expectation in the smartphone industry and are moving up steadily in the browser wars.

    The reason Microsoft is in the DOJs cross hair constantly is due to them deciding to inhibit 3rd party support and forcing their users to use MS products out of the box. If they were to block flash and only offer their product, then they are creating a monopolistic advantage. Of course Apple on the other hand are just dropping support for a specific technology, they arent doing it to promote their own competing technology. If they did prevent flash use so that they could push AppleLight or something then im sure the DOJ would be onto that..

  • A1programmer

    @Dan.
      You pretty much hit the nail on the head, this is far from replacing Flash. It only offers about .01% of what flash can do. Writing an an ActionScript3 interpreter in JavaScript will be a pretty daunting task. What do you do when you get to the capabilities of Flash that cannot (no way , no how) be done in JavaScript… I’d like to see him write a Socket client in JavaScript.

  • http://www.lunadesign.org awasson

    Craig Buckler:

    I agree that Adobe often produces some shocking software but, to me, Apple appear to be making a few too many excuses. They have good commercial reasons not to offer Flash but won’t say that.

    For the record, I’m not a Flash developer and I do think many people use it for frivolous effects which could be achieved using more appropriate standards-based technologies (HTML, CSS, JS, SVG etc). However, it’s a widely available plugin and does have its uses.

    There would be uproar if Microsoft prevented Flash running on Windows or IE (which would give Silverlight a boost). Should Apple be able to restrict what software is written for and used on their OS?

    Those are some good points to ponder.

    For the record, I think the tech for iPad/iPhone/iTouch is pretty spectacular. The iPhone/Touch interface is amazing for such a small device. All that said, I think Apple is doing its userbase a disservice by locking out a Flash plugin from the platform. Maybe I’m lucky but I’ve never crashed OSX or Linux by visiting a site that uses Flash and I have written and run some pretty bad actionscript ;)

  • dazweeja

    @W2ttsy, as you say, the reason the DOJ targets Microsoft is that they abuse their monopoly position. This cannot be said of Apple regarding the iPhone/iPad as they have a small share of the mobile phone market. They’re not even the largest in the smartphone segment. With their current market share, it would not matter one bit if they blocked Flash and pushed Apple Light. Small players are free to do this, just like Microsoft can do whatever they like with the Zune.

    As far as the original topic goes, Adobe are doing something about Flash. 10.1 uses 55% less memory on mobile phones than 10.0 and will be used by every smartphone manufacturer except Apple. It will also mean that some form of Flash will be on the phones of 19 of the top 20 phone manufacturers. If 10.1 is as big an improvement as Adobe hopes, it will be a big win for Google (Android) and Palm (WebOS). Then the ball will most definitely be in Apple’s court.

  • A1programmer

    When it comes down to it, the reason that Apple doesn’t want Flash running on their phones is because they want total control of what runs on their devices. Of course, Steve Jobs isn’t going to come out and say that, but it’s that simple.

  • http://www.optimalworks.net/ Craig Buckler

    @A1programmer

    Writing an an ActionScript3 interpreter in JavaScript will be a pretty daunting task.

    Would it? ActionScript is based on ECMAScript. There are some server-specific methods so you might need to implement Ajax-proxies, but I doubt it’s technically impossible. If a single Facebook developer can write a PHP to C compiler in 6 months, I’m sure some clever programmer can do the same for Flash (if it’s worth the effort).

  • A1programmer

    Craig,

         It actually would, at least for me anyway. Sure, some people are better at writing interpreters, compilers, etc. And there are some people who can do it better than others. But, all that aside. Just because PHP is syntactically like C++ doesn’t necessarily mean you can write a PHP interpreter in C++ any easier than any other language. The same goes for ActionScript3 and JavaScript. Of course, both are based on ECMAScript, in fact, since ActionScript3 is completely ECMAScript 3 compliant (with some features of 4). But executing the same code in JavaScript does not equal writing a AS3 interpreter in JavaScript. Of course, it would be much more logical to transform the code into JavaScript code. But back to my point, there are many features which the “runtime”, i.e. the Flash Platform supports that JavaScript run times do not. In non sandbox mode with the latest AIR SDK, you can write Socket Servers. True, it isn’t fair to compare AIR to Flash which runs in the browser, but the runtime supports it, it’d just have to be allowed by the end user in the flash player plugin (not likely, but not impossible). Implementing a proxied ajax type socket client isn’t technically implementing a socket client in JS.
     
       Also, the Facebook developer didn’t actually write a compiler, he transformed PHP into C++, then compiled it with g++. Very cool, nonetheless.

  • http://www.dangrossman.info Dan Grossman

    @Craig: It would have to interpret the compiled AS in the SWF file, not ActionScript source code. A decompiler and interpreter. That’s quite a challenge.

  • http://www.optimalworks.net/ Craig Buckler

    Good points, although a developer using Gordon may have access to his own Flash source code.

    Anyhow, I guess some Flash widgets will require Adobe creating JS/Canvas/SVG exporters in their tools.

  • A1programmer

    Yeah, very good point. Then comes the question: Why do this in Flash at all ? hehe. One could use something like APE (Ajax Push Engine), and write a pretty nice JavaScript / HTML5 app. There are some pretty cool JavaScript / Canvas games.