AS2 to AS3 Conversion Annoyances August 24, 2007
After using FDT and MTASC both with strict compilation, I was thinking that converting to AS3 would be straightfoward. Alas.. no.
Some of it is syntax, but frequently in the pursuit of performance or architectural benefits, I had to take advantage of tricks or in the language, and many of these hacks are breaking, or rather even some of the core features no longer work on the AS3 architecture.
Nullable types bye..
For all the type strict typing in AS3, one of the biggest annoyances is the removal of nullable types. This has had profound impacts on migrating code.
what used to be
public function doSomething(var aNum:Number):void{
if(aNum == null){
aNum = DEFAULT_NUM
}
}
Now I have to use  aNum:* which makes it harder to read, and now I have to introduce argument type checking in the method body, quickly adding to the size. Grr. What's silly is you can still create without initializing vars e.g.
var numA:Number;
//sometime later, what is numA before this?
numA = -1;
in addition, var obj:Object = numA is a legal call. So.
I'd be happy if they make a separate nullable type e..g NullableNumber that extends Number and that NullableNumber is itself finalized.
Initialization Â
The intialization into the function signatures is neat and increases readability, but totally flummoxes collections when your defaulting to the length of the array, here again we have to use the wildcard, which defeats type checking during compilation.
For in...GoodbyeÂ
For in was a useful tool to introspect values and interate over collections. Of course since this uses the prototype chain which is slow it's been relagated to only looking at the prototype chain, as most the variables and method have been moved to the fixed class inheritance, many uses of introspection have been broken, all over the place.

Add a Comment: