ActionScript 3 Types Annotating types


You can tell the compiler the type of a value by annotating it with :Type:

var value:int = 10; // A property "value" of type "int".

Function parameters and return types can also be annotated:

// This function accepts two ints and returns an int.
function sum(a:int, b:int):int {
    return a + b;

Attempting to assign a value with a mismatching type will result in a TypeError:

var sprite:Sprite = 10; // 10 is not a Sprite.