# getDefinitionByName with arrays

**URL:** <https://forum.kirupa.com/t/getdefinitionbyname-with-arrays/327186>\
**Category:** flash\
**Created:** [February 11, 2012, 4:07pm UTC](https://forum.kirupa.com/t/getdefinitionbyname-with-arrays/327186 "2012-02-11T16:07:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![FlashCS5Novice](https://avatars.discourse-cdn.com/v4/letter/f/8baadc/32.png) [@FlashCS5Novice](https://forum.kirupa.com/u/FlashCS5Novice)\
**Post date:** [February 11, 2012, 4:07pm UTC](https://forum.kirupa.com/t/getdefinitionbyname-with-arrays/327186/1 "2012-02-11T16:07:48Z")

</div>

Hi guys! I’m having a new problem today- referring to arrays with getDefinitionByName. I looked aound for an answer, but couldn’t find anything, so here I am!

Anyways, in my map editor, I will have two layers of objects, and the user is responsible for choosing which layer of the map to write to. Because of this, I won’t know the exact name of the array to write to until I piece together the string “map0Layer” and selectedLayer (chosen by the user):

```auto
var targetString: String = "map0Layer"+selectedLayer;
    var mapTarget = getDefinitionByName(targetString) as Array;
    trace(mapTarget);

```

Through this, I’d like to refer to an array, but every variation of the above code I’ve tried resulted in

> ReferenceError: Error #1065: Variable map0Layer1 is not defined.

(this is subject to change because it could be “map0Layer2” as well, but you get the idea.)

Anyone know of a solution?
