# Can a string be converted to an object name?

**URL:** <https://forum.kirupa.com/t/can-a-string-be-converted-to-an-object-name/250678>\
**Category:** flash\
**Created:** [January 31, 2008, 4:48pm UTC](https://forum.kirupa.com/t/can-a-string-be-converted-to-an-object-name/250678 "2008-01-31T16:48:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lkingman](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@lkingman](https://forum.kirupa.com/u/lkingman)\
**Post date:** [January 31, 2008, 4:48pm UTC](https://forum.kirupa.com/t/can-a-string-be-converted-to-an-object-name/250678/1 "2008-01-31T16:48:46Z")

</div>

- 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.
