Hello folks!
This is my first post and I’m on a huge project I’m creating myself, but the path is blocked from now.
I have two classes: the superclass “Unit” and the subclass “Infantry”. Im trying to use a dynamic class when Im sending a MovieClip (thats what I want, sending MovieClips from the Library to classes directly and dynamicaly) from the Library to Unit (heres the code):
public function Unit(x:int, y:int, dZ:int, def:String){
this.x = x;
this.y = y;
this.dZ = dZ;
var unitClass:Class = getDefinitionByName(def) as Class;
unitMC = new unitClass() as MovieClip;
this.addChild(unitMC);
…
}
And in Infantry:
public function Infantry(x:int, y:int, dZ:int, def:String){
super(x, y, dZ, def);
}
And In the document class “Engine” I just want to simply create an obect of Infantry:
public var soldier:Infantry;
public function Engine(){
soldier = new Infantry(150, 220, 30, “soldier_mc”);
Now the problem is that I get this error:
ReferenceError: Error #1065: Variabel soldier_mc has not been defined
at global/flash.utils::getDefinitionByName()
at Unit()
at Infantry()
at Engine()
I have searched the forum and FAQ and have found no right answers and even searched in google but no use.
I wish for both a hand and help