# ReferenceError: Error #1065

**URL:** <https://forum.kirupa.com/t/referenceerror-error-1065/311660>\
**Category:** Uncategorized\
**Created:** [July 13, 2010, 5:12pm UTC](https://forum.kirupa.com/t/referenceerror-error-1065/311660 "2010-07-13T17:12:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SirRiche](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@SirRiche](https://forum.kirupa.com/u/SirRiche)\
**Post date:** [July 13, 2010, 5:12pm UTC](https://forum.kirupa.com/t/referenceerror-error-1065/311660/1 "2010-07-13T17:12:17Z")

</div>

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
