Hello I have this bit of code, and it what it must do is when there is some class (always extending the Box class) that must be spawned if there is already one of the same type it loads that one and if there is no one it creates a new one.
private var _l:Vector.<Box> = new Vector.<Box>();
public function respawn(shapeId:int, className:String = "Box"):Class {
var l:int = _l.length, i:int;
var c:Class;
var ct:Class = getDefinitionByName(className) as Class;
for (i = 0; i < l; i++) {
c = _l[i];
if (!c.active && c.shapeId == shapeId) {
return c;
}
}
c = new ct();
_l[l] = c;
return c;
}
If I try this code it generates these errors:
Implicit coercion of a value of type com.shapes:Box to an unrelated type Class.
Implicit coercion of a value of type Class to an unrelated type com.shapes:Box
How can I fix this so I can create different types of classes that all extend the Box class and get them into a Vector.<Box>?
Object is the superclass of all ActionScript classes, not Class.
Besides, you can:
But you can not: