PDA

View Full Version : Contents of a Var -> Name of new Var


Lienne
09-06-2005, 04:30 PM
How would I use the contents of a variable as a variable name? Somehow, I've made it quite a ways into AS without knowing how to do this!

For instance, I have the word "melon" stored in the variable "fruit"

I would then like to turn "melon" into it's own object and add an array of it's parts dynamically.

Help! I know it's got to be so simple, I'll kick myself.

Xeef
09-06-2005, 07:00 PM
fruit="melon";
_root[fruit]="fruit"
trace(melon) // fruit

:D

Xeef
09-06-2005, 07:04 PM
http://www.actionscript.org/forums/showthread.php3?t=52592

was my first Question on the forum

Lienne
09-06-2005, 11:18 PM
using that, how would I assign it a data type?

For instance: this[fruit]:XMLNode

Xeef
09-07-2005, 01:16 PM
NO way to do this !

Lienne
09-07-2005, 09:15 PM
thanks for your help!