Can a string be converted to an object name?

  • I have multiple mxml elements: " … id="myName1, id="myName2 … id="myNameN>
  • I want to call a function to act on all these elements such as …

function doSomethingRepeatedly () {
for ( … ) {
var thisName:String= … concatenate “myName” & sequential numbers
doSomething(thisName)
}
}
function doSomething(whichElement) {
… convert the string contained in “whichElement” to an object name “thisElement”
thisElement.someProperties=someData
}

  1. Can I convert the string input to an object this way?
  2. Is there a better way to do this?

Thanks in advance for any help.