# Help with getDefinitionByName

**URL:** https://forum.kirupa.com/t/help-with-getdefinitionbyname/322701
**Category:** flash
**Created:** [May 31, 2011, 10:24am UTC](https://forum.kirupa.com/t/help-with-getdefinitionbyname/322701 "2011-05-31T10:24:45Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![sami016](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@sami016](https://forum.kirupa.com/u/sami016)
#### Post date: [May 31, 2011, 10:24am UTC](https://forum.kirupa.com/t/help-with-getdefinitionbyname/322701/1 "2011-05-31T10:24:45Z")

</div>

Hey, Im having some trouble with getDefinitionByName. Basically I have a class called “tower\_arrow”. I can create this tower and it works fine like this:

```auto
var pr = new tower_arrow();

```

However, I need a system that loads different towers based upon string input, so I tried replacing this with:

```auto

var C2:Class = getDefinitionByName( "tower_arrow" ) as Class;
var pr = new C2();

```

However, I get an error when running this second code:

```auto
ReferenceError: Error #1065: Variable tower_arrow is not defined.
	at global/flash.utils::getDefinitionByName()
	at code.world::world/newTower()
	at code.world::placer/tryCreate()
	at code.world::placer/go()

```

I can’t see why this wouldn’t work, the class works fine, I have imported it into the document I am using it in.

Thanks.
