# Substituting A Variable

**URL:** <https://forum.kirupa.com/t/substituting-a-variable/309576>\
**Category:** flash\
**Created:** [May 19, 2010, 1:21am UTC](https://forum.kirupa.com/t/substituting-a-variable/309576 "2010-05-19T01:21:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jephz](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@Jephz](https://forum.kirupa.com/u/Jephz)\
**Post date:** [May 19, 2010, 1:21am UTC](https://forum.kirupa.com/t/substituting-a-variable/309576/1 "2010-05-19T01:21:16Z")

</div>

Hi Newgrounds, need some help here.

I was wondering if its possible to substitute a variable with another variable’s **name** instead of its actual **value**. Not sure what I mean? Let me explain.

I have a variable named “ **pLeg** ” thats equal to the value of 1.

I have blank variable named “ **itemVar** ”.

Now, I want “ **itemVar** ” to equal to “ **pLeg** ”, but not of its value, but of its name string.

The reason is because I need “itemVar” to substitute multiple variables in a main timeline code.

For example:

```auto

if(_root.itemVar !== 1) {
//do something
}

```

“itemVar” can be any variable, like pTorso, or pWeapon or anything. Which is why I can’t have it equal to the variables actual value, because then the timeline code would turn out to be:

```auto

if( 1 == 1) {
//1 being itemVar
}

```

Any thoughts?

PS: I’ve tried add quotations like \_root.itemVar = “pLeg” but Flash will not read it as a variable.

-Jephz
