# getDefinitionByName problem

**URL:** <https://forum.kirupa.com/t/getdefinitionbyname-problem/276404>\
**Category:** flash\
**Created:** [November 26, 2008, 7:56pm UTC](https://forum.kirupa.com/t/getdefinitionbyname-problem/276404 "2008-11-26T19:56:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![john\_paparis](https://avatars.discourse-cdn.com/v4/letter/j/ea5d25/32.png) [@john\_paparis](https://forum.kirupa.com/u/john_paparis)\
**Post date:** [November 26, 2008, 7:56pm UTC](https://forum.kirupa.com/t/getdefinitionbyname-problem/276404/1 "2008-11-26T19:56:06Z")

</div>

hi  
i am loading class names through an xml file. i use the full package name for example  
site\_classes.pages.graphic\_space.Graphic\_space is the string of one class i am trying to load. inside the main class of the application i use the following code to instantiate this class, after having imported the classes as well.

var new\_class\_name:Class=getDefinitionByName(class\_name) as Class;  
var my\_obj:Object = new new\_class\_name();  
( class\_name stores the string name of the class);

when i do this i get the following error :  
ReferenceError: Error #1065: Variable Graphic\_space is not defined.

but if i hardcode it \> var my\_obj =new Graphic\_space ();  
everything works fine.

to make things even more complicated if before the call to getDefinitionByName i place a trace to the full package path of the class for example trace(site\_classes.pages.graphic\_space.Graphic\_space as Class) it works !!!  
why the getDefinitionByName function throws an error ??? if there is no trace before ???  
can someone help me ?
