Cover image from AS3 Frosty Toes

AS3 Frosty Toes

February 12, 2009

I recently dipped my toes into the Actionscript 3 toes. This is quite a readjustment from the experience of the past 7/8 years of traditional actionscript development. I was somewhat prepared after having done a lot of projects with Object Oriented programming languages. Specifically Java and C# (VB sucks balls). I, along with most actionscript developers, tried to con ourselves that first abusing the prototype property and then the abortive actionscript 2 was actually OOP.

It isn’t, without a proper implementation of inheritance it is as best a self imposed guideline, at worst an abomination of hacked spaghetti code. So, key concepts of AS3, I found the following to be the most important:

  • Base types are now respected, and objects can be cast back to the base type, or the super class
  • Code is executed in each cycle, then the display is updated
  • Performance increase is significant, but like all things, not to be abused
  • Creation complete means just that, the object is ready to be used and all properties are available
  • Event based code is integral

Of course, with every language, there is new syntax and paradigms. The display list is a new concept, but a lot more flexible and intuitive than old methods. Underscores as part of properties are a thing of the past. Thanks to event based model, lines like: _parent._parent._parent._parent.myTextField.text="1,2,3,4 levels up, I think..." are a thing of the past. The standard FLVPlayback component no longer fills me with dread.

Missed oppertunities, there are a few (there always are). Typed arrays, conspicuous in their absence. Most programs now end up with more casts than broadway. Why is the floating point precision type called Number, aren’t integers numbers too? Wouldn’t float/double be more concise? Proper polymorphism would have been nice too.

Overall though, the niggles are small. For me, this is a massive improvement in workflow, with a newly discovered confidence in how the runtime will handle the code.