Here are some of the new features in ActionScript 2.0, and why one would want to use it instead of ActionScript 1.0 (yes, you can still use the older syntax in Flash MX 2004).
ActionScript 2.0 is not a new language. It is an enhancement to the previous version, by building on the existing language. In fact, Flash MX 2004 compiles AS2 into AS1 equivalent bytecodes. One reason for this is backwards compatibility in Flash Player 6. As a result, one can code in AS2 and compile it for Flash Player 6. For better optimization, target for Flash Player 220.127.116.11 or higher. Some version 2 components won’t run except in FP7, but some can run in 18.104.22.168 as well.
In terms of building applications, ActionScript 1.0 (and ECMAScript 3 in general) requires getting intimate with something called the prototype (and __proto__ if you’re a rebel trying to avoid unwanted side effects). The reason being that there was no ‘class’ construct, and inheritance was done in a very odd way.
Now in ActionScript 2.0, it is more suitable for OOP because of the following new keywords and features:
class, interface, extends, implements, private, public, dynamic, instrinsic, static, get, set, import; class path (similar to package), and strict data typing (useful in locating problems at compile time).
With these new features in ActionScript 2.0, building robust applications is becoming more attractive, and in a way easier. However, because Flash MX 2004 does not care if AS1 or AS2 is used (in most cases), one can still continue using AS1 and slowly migrate over to AS2.
7 replies on “ActionScript 2.0”
If AS2 if compiled down to AS1 equivalent, what is the internals techniques to do inheritance ?
IMHO, building classes in AS2 targeting 6.0.65 player should keep the same bugs, isn’ it.
Or is it a different way due to bytecode ?
It should also use the ‘new’ inheritance way of doing things when publish to 6.0.65. Am I Right ?
Yes, inheritance (extends) is still compiled to the ‘new’ statement:
SubClass.prototype = new SuperClass();
However, the super class invocation bug is fixed for the Flash Player 7 internally with a new opcode.
So then, Dave, shouldn’t we have follow the MM inheritance style (with the crazy workarounds : NO_INITS etc.) already in Flash MX and continue to cope with it now ?
I’m quiet interested in using fMX2k4 to publish to 6.0.65. But I was thinking that I took some much time to create a well design OOP lib in MX, and that it could be used in MX2k4 IDE…
Do you think it is possible to mix class based porgramming with the idea to publish to 6 and import Peter Edward’s found for better prototype referencing ?
And, to finish, since AS2 is compiled to AS1, doesn’t we be aware of the old odd inheritance problems we got with the ‘new’ way of doing things ?
My thought is : why designing well at authortime when all the stuff doesn’t convert well once compiled ?
Do you get me ?
Thanx, nevertheless for your answer.
I think i’ll continue to work with MX until the player read AS2, not converted one.
Sure you can continue to use your existing AS1 library (with the workaround solutions) for publishing to FP6.
However, the nice thing about AS2 is that the code is more organized, with less non-standard workaround hacks (which I’ve created quite a few in the last three years!), and compile-time checking.
Mixing AS1 and AS2 is not an ideal solution for the long run. Having said that, sometimes you still can’t get away from AS1, when AS2 does not offer an alternative (such as climbing the inheritance chain). Believe it or not, __proto__ (ECMA-depreciated) is used in the base class of all UI objects! 😎
__proto__ (ECMA-depreciated) is used in the base class of all UI objects!
LOL, arf arf.
so the rebel alliance is not dead… live and kicking !
thanx for your insights, and all the past other ones.
Why was the normal mode erased?