i am trying to pass a class type into a function which then declares it to an array this way:
i have this class which i am using the add movieclips form the library.
package {
import flash.display.MovieClip;
public class TestClass extends MovieClip {
private var allTypes:Array;
public function TestClass {
allTypes = new Array();
}
public function addType(i:Number, type:*) {
//then i wanna declare the type of the class that is put into this method
allTypes* = new type("name", 10, 50);
addChild(allTypes*);
}
}
}
and then on my main timeline, i have this document class, which will have an instance of the TestClass, and add in types which i want to add onto the stage. i wish to pass in the type of the class name of the exported movieclips which i have in my libraries.
package {
import flash.display.MovieClip;
import TestClass;
public function MainMovie extends MovieClip {
var TestClass:TestClass;
public function MainMovie() {
TestClass = new TestClass();
//now i want to add the Type of the class into the paramaters
//these types are class names of the movieclips in the library that are exported for actionscript in linkage
TestClass.addType(0, Plane);
TestClass.addType(1, Bird);
}
}
}
however, this doesn’t seem to work. any idea how should the syntax or the right way be for doing this?
thanks.