# Using dynamic variables names

**URL:** <https://forum.kirupa.com/t/using-dynamic-variables-names/224886>\
**Category:** Uncategorized\
**Created:** [May 6, 2007, 8:22pm UTC](https://forum.kirupa.com/t/using-dynamic-variables-names/224886 "2007-05-06T20:22:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gnaws](https://avatars.discourse-cdn.com/v4/letter/g/6a8cbe/32.png) [@Gnaws](https://forum.kirupa.com/u/Gnaws)\
**Post date:** [May 6, 2007, 8:22pm UTC](https://forum.kirupa.com/t/using-dynamic-variables-names/224886/1 "2007-05-06T20:22:08Z")

</div>

I have a list of variables loaded from a MySQL database. I can access them from my nested MC if I type in the exact variable name like this:

```auto

on (press) {
    trace ("word3 = " + _parent.word3); // good!!
}

```

But I can’t access them using dynamic variables. I’ve included my code showing how I’ve tried to access them along with their respective responses.

```auto

on (press) {
    _global.i = i++;
    trace("_global.i = "+i++);
    //trace("word3 = "+_parent.word+i); // undefined
    //trace("word3 = "+_parent["word"+i]); // no
    //_parent.answer = _root["word"+i]; // literal string =[
    //_parent.answer = eval("word"+i); // undefined
    // _parent.answer = eval(word+i); // NaN
    //trace("answer = "+(eval("word"+i))); // LOCK UP!

    trace(_parent.answer);

    this.gotoAndStop(1);
}

```

Thanks in advance.
