I have an array containing names lets say,
var myArray:Array=new Array("name1","name2","name3");
Now I want to use the array values as the object properties by iterating through the arr开发者_如何学运维ay I meant I want the object to have name1,name2,name3 as the properties,
var myObject:Object=new object();
for(var i:int=0; i<myArray.length; i++){
myObject[myArray[i]]="something";
}
but this does not give me the required result, it sets the object property as myArray[i] i.e, whatever I give inside the square braces is taken as a string in this case.I want the output to be,
myObject[name1]="something"
myObject[name2]="something"
myObject[name3]="something"
but instead it gives the output as
myObject[myArray[i]]="something"
Any ideas how to do this?
Not sure I fully understand, but I think you've accomplished your goal.
In the debugger, I see:
Was this not what you want?
I believe what you've stated is equivalent.
精彩评论