Skip to main content
Inspiring
June 17, 2006
Answered

Access Variable from a dynamic name

Hello,

I have a the following example variable in a script defined as such:

mcDrg05OriginalX = mcDrg05._x;

I wish to access this variable data within a button script, but dynamically by assembling the actual variable name:

newName = holdName[landingCount];
relocateIDx = (newName + "OriginalX");

newName accesses the original name from an array, and relocateIDx assembles the full variable name to be mcDrg05OriginalX. Now I wish to access the original numerical value from that variable name, but how?

I tried:

_root[newName]._x = (relocateIDx);
_root[newName]._x = [relocateIDx];

maybe the answer is out there.

Thanks in advance.
This topic is closed to new replies. Start a new post to keep the conversation going.
D__J__FaberCorrect answer
Inspiring
June 17, 2006
Never Mind. I should of searched before.

If I use:
relocateIDx = eval(newName + "OriginalX");

this now gives the original number
Thanks

1 reply

D__J__FaberAuthorCorrect answer
Inspiring
June 17, 2006
Never Mind. I should of searched before.

If I use:
relocateIDx = eval(newName + "OriginalX");

this now gives the original number
Thanks
Translate