ActionScript 3 Types The Class type

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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);


Got any ActionScript 3 Question?