Wednesday, August 6, 2008

Actionscript 3 and the JVM

I've recently been ridiculed multiple times by uninformed Java developers for claiming that Actionscript3 runs on the Java Virtual Machine. In particular, the people in ##java got quite miffed at me for suggesting there was a relationship.

I'll admit I was fuzzy on the details of the relationship between Flash CS3 and Java, and searching didn't reveal anything that conclusive. Was it a built in, stripped down, modified version? Was it licensed from Sun or grown in-house at Adobe? I can't find it offhand, but a benchmark comparing Ationscript 1 through 3, Javascript, and Java revealed suspiciously similar numbers between AS3 and Java. Also Flex uses the ANT build system, which is a Sun/Java related animal.

So there was a blurry but definite relationship between the two in my mind. I stumbled on a lot more conclusive evidence while solving an elusive failure in Flash CS3's optimizer, though.

At least for Actionscript 3 projects, Flash CS3 compiles your code down to Java bytecode. It uses the Java compiler, the Java optimizer, and runs on an unmodified Sun Java Virtual Machine. The only part of the process that is any different from actual Java itself is the parser, and that's not all that different - as of AS3, Actionscript sure resembles Java a lot.

Single inheiritance, multiple interface, object oriented, strongly typed (well, you can get away with more loose typing but it's discouraged), packages, etc. It's not drastically different.

So this has me wondering - how many Java debugging tools, decompilers, etc could be used with Flash .swf's with very little jerry rigging...

0 comments: