# Dynamically accessing arrays

**URL:** <https://forum.kirupa.com/t/dynamically-accessing-arrays/215009>\
**Category:** flash\
**Created:** [February 2, 2007, 10:51pm UTC](https://forum.kirupa.com/t/dynamically-accessing-arrays/215009 "2007-02-02T22:51:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![blitzman](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@blitzman](https://forum.kirupa.com/u/blitzman)\
**Post date:** [February 2, 2007, 10:51pm UTC](https://forum.kirupa.com/t/dynamically-accessing-arrays/215009/1 "2007-02-02T22:51:34Z")

</div>

I’ve have a question about dynamically accessing arrays. I’m going to have a number of arrays, char\_a, char\_b, char\_c, etc…

The values of these arrays will be used to load in other movie clips, x, y, scale, color, etc…

\_root.char\_a =[15,20,100]

I have a function to load in movie clip based on a given array, the variable I’m passing to the function is going to be a, b, c, etc… So if I pass ‘a’ to the function I want to load in the movie clip based on the values in “char\_a”, [15,20,100].

function loadCharLoc(name) {  
x = this[‘_root.char_’ + name][0];  
y = this[‘_root.char_’ + name][1];  
moviename = ‘grid\_char\_’+name;  
\_root.main\_grid.attachMovie(moviename, moviename, getNextHighestDepth(), {\_x:x, \_y:y});

When I trace the values of x or y I get undefined. Any suggestions on whats wrong with this and how to fix it.

thanks
