getDefinitionByName with arrays

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):

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

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?