# getDefinitionByName not work

**URL:** <https://forum.kirupa.com/t/getdefinitionbyname-not-work/321199>\
**Category:** flash\
**Created:** [April 13, 2011, 9:00am UTC](https://forum.kirupa.com/t/getdefinitionbyname-not-work/321199 "2011-04-13T09:00:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![acrylics](https://avatars.discourse-cdn.com/v4/letter/a/3e96dc/32.png) [@acrylics](https://forum.kirupa.com/u/acrylics)\
**Post date:** [April 13, 2011, 9:00am UTC](https://forum.kirupa.com/t/getdefinitionbyname-not-work/321199/1 "2011-04-13T09:00:42Z")

</div>

why i can’t get a class defined by embed a .png file.  
like this:  
[COLOR=Blue][Embed(source = “…/assets/level1/liquid4.png”)]  
public var Liquid4:Class;[/COLOR]  
then in the same class:  
[COLOR=Blue]var str:String = “Liquid” + 4;  
var disClass:Class = getDefinitionByName(str) as Class;  
addChild(new disClass() as DisplayObject);[/COLOR]

there is nothing shows up and no error report.the program seems stoped at the  
[COLOR=Blue]getDefinitionByName [/COLOR]line.what could be the problem,and how to get a style like this when i have multiple embeded image to go over.thanks .

* * *

## I learned that getDefinitionByName needs the class name as its parameters.which is not [COLOR=Blue]Liquid4[/COLOR],[COLOR=Blue]Liquid4[/COLOR] is just a varialbe that hold the reference to the actual class object. Well i did get things work,but there is another problem: -I’m using FlashDevelop as my IDE environment,the root folder “scr” which has [COLOR=Red]“Main.as”[/COLOR] and [COLOR=Red]“Preloader.as”[/COLOR] class in it.when i test my class uint which Embeded the Fluid4 Class,it works,everyone is happy.but later i decided to move it to a separate folder under the root [COLOR=Red]“src” [/COLOR]folder.things get ugly,and error shows up indicating “can’t find the class”,The Embed picture class.but then i moved it out the subfoler ,everyThing works again fine.what’s the matter with this .seems FD’s own problem or what…please give me some hint.

## [COLOR=Blue][Embed(source = “…/assets/level1/liquid4.png”)] public var Liquid4:Class;[/COLOR] then in the same class: [COLOR=Lime]//This gives us the actual class name[/COLOR] [COLOR=Blue]var str:String = “My Class Name”+"\_"+Liquid" + 4; var disClass:Class = getDefinitionByName(str) as Class; addChild(new disClass() as DisplayObject);[/COLOR]

This did work,but only in the “src” source file folder,not a sub folder of it.I checked this phenomenon many many times,and did use a tiny snippet program to prove it.It just doesn’t work in the subfolder of “scr” root folder.
