By Sibers CTO Andrew Gavrilov.
Former versions of ActionScript seemed to be more of a Flash appendix, therefore I didn’t study them in detail. This new third one claims to be something for big guys. Here are the big guy’s impressions.
Good things first.
First of all, AS3 introduces a well designed JIT compiler, which ensures appropriate performance.
Secondly, its compatibility with the ECMA standard means that even if the language was designed by idiots, we can implement all needed things in it. With minimum overheads for learning it.
But… as I dig deeper, I run into annoying surprises…
For example there are two inheritance methods. One follows the ECMA standard, the other is compatible with the Flash Player API and increases performance. I can’t believe that it wasn’t possible to make it straightforward…
Another interesting moment is associative massives (hashes). AS3 uses the Object class for them. Prototype ECMA inheritance allows adding new properties to the objects, which we are supposed to use. And there are no methods like “length”! There’s also a special class Dictionary that allows using objects as keys, but it works the same dumb way i.e. via adding a property.
To sum it up: pretty usable, but quite nasty.
***
Few words about MX Framework (Flex 2) – default framework AS3 for building interfaces.
Big advantages are one of the most developed Layout system, basic description of the interface in XML (.mxml files) and utilization of CSS. No complaints here except for against a pretty weak visual editor in IDE.
And again, we dig deeper…
For example, we create a visual component and want to know its width. Where would you look? Into a “width” property? Nope – it’s equal to zero. Value of this field (just like all others with sizes and coordinates) is shown only if it’s assigned there.
Solution is original: first of all we call measure method. So we make the component measure itself. After that we get the width value with getExplicitOrMeasuredWidth method, which returns the measured value if none was assigned.
Or take another example. I want to get coordinates of an icon in a button. There’s no external access to the icon properties even for the inheritors of Button (I, as a true believer of OO programming, created an inheritor for all these experiments). Okay, let’s go to the hidden properties via namespace mx_internal and voila – now we see why Adobe developers hesitated to show this to everyone: the coordinates of an icon are calculated beginning from the nearest button border. This means that depending on the mutual position of the icon and text, we get different coordinates of the icon each time. Brilliant idiocy!..
I agreed with you