ActionScript 3 Types The Class type


Example

References to class declarations are typed Class:

var spriteClass:Class = Sprite;

You can use variables typed Class to instantiate instances of that class:

var sprite:Sprite = new spriteClass();

This can be useful for passing an argument of type Class to a function that might create and instance of the provided class:

function create(type:Class, x:int, y:int):* {
    var thing:* = new type();
    
    thing.x = x;
    thing.y = y;
    
    return thing;
}

var sprite:Sprite = create(Sprite, 100, 100);