I’m trying to write a class which can spawn many instances of a given sprite. Something like…
package {
import flash.display.Sprite;
public class particlePlane extends Sprite{
public function particlePlane(particleType:Object, ammount:uint, planeWidth:uint, planeHeight:uint) {
trace("particlePlane: Populating with "+ammount+" "+particleType);
for (var count = 1;count <= ammount; count++) {
var particle = particleType;
particle.x = Math.random() * planeWidth;
particle.y = Math.random() * planeHeight;
this.addChild(particle);
}
}
}
}
The trouble is I want it to work with any sprite, so I don’t have to import each and every type. Is it possible to pass a class reference like this?