Friday, February 08, 2008

Actionscript 2 is terrible

I've been doing a some flash development for work recently. It mostly involves adding features to an already existing flash project, which means its written in Actionscript 2.

I was really excited to learn AS2. Javascript is already one of my favorite languages, but it's sometimes a pain to deal with because of cross browser API and language differences. Since actionscript is an ecmascript dialect as well, I hoped that working with AS2 would be just like writing JS, but without the JS headache.

The reality was totally different: Flash 8/AS2 is the most painful to use development platform I've ever had to deal with. No joke. Here are some highlights:

1. In any sane dynamic language, what would you expect the output of this to be?

var x = undefined;
x.doIt();

I'd expect it to kick and scream. What does AS2 do? absolutely nothing. It just proceeds happily along as if nothing happened. You can imagine the silent failures and the hard to debug problems this can cause.

2. Speaking of debugging, if you were hoping to see a stacktrace anywhere, you can forget about it. This is also one of the most annoying things about working in javascript as well.

3. setTimeout is a pretty useful function. In fact, its so useful that it was added in the AS2 standard library. However, if you try to call it from an actionscript class, it'll fail to compile: it was just left out of the namespace! Thankfully, it's still callable if you tell the compiler to bugger off:

_global.setTimeout(function () { ... }, 300);

I'm amazed Macromedia's QA let this product launch with this bug. I'm even more amazed it was never fixed in any flash 8 player/compiler updates.

4. When the Flash CS3 compiler detects an error, it adds a line of text into a "compiler errors" window, which by itself isn't too bad. However, it still outputs a SWF and tries to execute it anyway. Not only does this slow down the development cycle, but it also squashes your perfectly good SWF from your previous compile.

5. AS2 doesn't include regular expressions in it's standard library. Awesome.

There's a lot more I could whine about: combo boxes that stop working once your SWF is dynamically loaded in another, buttons that stop responding to click events once you give focus to a text entry box, tedious manual merges of FLA files, strange delayed initialization issues, etc. Overall, it's really terrible. It's pretty clear to me that Macromedia didn't really care about flash as a development platform, and were happy with it just being used for animation.

Thankfully, AS3 seems to be much more pleasant to work with. I don't know if this due to Adobe's influence, or if Macromedia finally started to take flash as a dev platform seriously after flash 8. If you are starting a new flash project now, don't bother with AS2, just do it in AS3. Flash 9 already has 96%+ penetration in the US, the upgrade process is relatively painless for most flash 8 customers, and your developers will be much happier.

Labels: