Monday 18 April 2011

Flash vs. JavaScript - The times they are a-changin'



Recently I started delving into Adobe's journey through code, via ActionScript 3.0. The 3+ version of ActionScript is what I'd describe as nearly object oriented. It's got classes, like Java, but it reads like JavaScript. Rest assured it's hanging on the Java tree as far as language inheritance goes.

It's actually based on the ECMA scripting language (same as JS), and so naturally it shares a lot with JavaScript. The utility of the Flash runtime is it's native geometric toolkit for drawing shapes and making animations. It also has a variety of open-source classes available, ported from other languages to be fully compatible with the Flash runtime.

Although Flash is the 'de facto' toolkit for web graphics because of its popularity with designers, currently more and more people are using the native web language HTML and JavaScript only. HTML5 has a canvas for creating and modifying shapes, like Flash. Apparently, it's quite good.

More and more ports to WebGL in JavaScript are cropping up, through the development of extensive library packages like this one. Also Mr Doob and AlteredQualia have written a port to WebGL for JavaScript called three.js, and it is pure delight to see the results they've got out of it. The equivalent for Flash is the slightly less sophisticated, but still highly useable Papervision3D.



An example of the difference between a series of Bezier curves (top) and a spline curve - spline much smoother and more 'natural'.













The way that graphics software developers (read: mathematicians) think is this: what formula best summarises the 'physics' of what you want to see on the screen? For example fire is a common request. In order to make a 'virtual fire' you have to create all the necessary elements for it to work. You have to feed it fuel and oxygen, and you have to represent the burning through the use of the Planck Energy Distribution Equation. I find this very interesting. And if you like that sort of thing, there's a very well written web page here by Hugo Elias.

Here is an explanation of the Planck Energy Distribution Equation.

The availability of pseudocode is essential for the transfer of knowledge across the dark art of computer programming.

No comments:

Post a Comment