# Whats up with GetDefinitionByName()?

**URL:** <https://forum.kirupa.com/t/whats-up-with-getdefinitionbyname/326883>\
**Category:** Uncategorized\
**Created:** [January 19, 2012, 3:29am UTC](https://forum.kirupa.com/t/whats-up-with-getdefinitionbyname/326883 "2012-01-19T03:29:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaChillWizard](https://avatars.discourse-cdn.com/v4/letter/d/b487fb/32.png) [@DaChillWizard](https://forum.kirupa.com/u/DaChillWizard)\
**Post date:** [January 19, 2012, 3:29am UTC](https://forum.kirupa.com/t/whats-up-with-getdefinitionbyname/326883/1 "2012-01-19T03:29:46Z")

</div>

Background info : I’m trying to be able to load the shape of a fruit and the color of the fruit as two separate Sprites from a SWC file using the name distinguish which Sprite to load.

This is so I can have a apple shape with orange skin or the other way around. Im hoping this well make it easy down the line to simply add the texture of a strawberry but have it masked on an banana shape or any other shape.

## But… From my understanding this code

```auto

tempClass = getDefinitionByName(_model._skin.name) as Class;        
                
_skin = new tempClass();
            
tempClass = getDefinitionByName(_model._body._structure.name) as Class;        

_body = new tempClass();

```

* * *

Gives me this -\>

:trout:

ReferenceError: Error #1065: Variable Apple\_Skin is not defined.  
at global/flash.utils::getDefinitionByName()  
at classes.creature.mvc::View()  
at classes::Main()  
at battleproto\_fla::MainTimeline/frame1()

:trout:

## unless I have the names of the classes explicitly written out before like so

```auto

Apple_Skin; //green color Sprite        
Apple_Body; //apple shape

Orange_Skin; //orange colored sprite
Orange_Body //orange shape
            
tempClass = getDefinitionByName(_model._skin.name) as Class;        
                
_skin = new tempClass();
            
tempClass = getDefinitionByName(_model._body._structure.name) as Class;        

_body = new tempClass();

```

* * *

I’d like to be able to easily add to the list of fruits but I dont want to manually type out each one. Is there an easier way to handle this so it wont be so cluttered? Thanks in advance wise ones :yoda:

:mu: DaChillWizard :mu:
