May
15
2009
AS3.0 TutBits #04: Untyped variables
When you create a variable in ActionScript you normally add its type, e.g.
var age:uint;Whenever you assign to that variable a value of another type the compiler will throw type mismatch errors.
// This will result in a type mismatch error age = -10;
Actionscript provides untyped variables. You can set them explicitly with the datatype “*“, e.g.:
var anything:*; anything = 10; anything = "Test"; anything = new Array();
Above code will not throw any type mismatch errors, because the variable is declared as an untyped variable. So you can assign values of any kind to it.
From my personal point of view however, you should avoid using untyped variables whenever you can.
