create variable with an argument as part of the name

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • x3n0s
    New Member
    • Mar 2008
    • 1

    #1

    create variable with an argument as part of the name

    Sorry for the completely uninformed question, but I'm trying to create a variable with a function that passes part of the variable name by an argument like this:


    Code:
    function doit(testvar:Object):void {
    	var this["mc_"+testvar] = "Overview";
    }
    doit("test");
    In this example, I'm trying to create a variable called mc_test but this doesn't work. to my understanding this["mc_"+testv ar] will create a string of "mc_test" but I can't set that string as a variable name.

    Any help would be greatly appreciated.
Working...