Only untyped variables can contain the value undefined . Optional variables are variables that either do not have annotations of any type or use the asterisk * character to annotate a type.
From ActionScript data type descriptors :
In previous versions of ActionScript, a variable without an annotation type was automatically assigned the data type of the object. This is no longer the true value in ActionScript 3.0, which now includes the idea of a truly untyped variable. Variables without type annotation are now considered untyped. If you prefer to explain to your code readers that you intend to leave the variable untyped, you can use the new asterisk (*) character to annotate the type, which is equivalent to excluding the type annotation. The following example shows two equivalent operators, both of which declare an untyped variable:
var x var x:*
Only untyped variables can contain the value undefined. If you try to assign an undefined value to a variable of a data type, Flash Player or Adobe AIR converts the undefined value to the default value of that data type. For instances of an object's data type, the default value is null, which means that Flash Player or Adobe AIR will convert undefined to null if you try to assign undefined to an instance of the object.
As an example:
var t:* = undefined; trace(t); // outputs: undefined var t:Object = undefined; trace(t); // outputs: null
source share