# AS2 - Saving with variable in variable name. Help please!

**URL:** <https://forum.kirupa.com/t/as2-saving-with-variable-in-variable-name-help-please/310188>\
**Category:** flash\
**Created:** [June 3, 2010, 3:39pm UTC](https://forum.kirupa.com/t/as2-saving-with-variable-in-variable-name-help-please/310188 "2010-06-03T15:39:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tcooley2003](https://avatars.discourse-cdn.com/v4/letter/t/e19b73/32.png) [@tcooley2003](https://forum.kirupa.com/u/tcooley2003)\
**Post date:** [June 3, 2010, 3:39pm UTC](https://forum.kirupa.com/t/as2-saving-with-variable-in-variable-name-help-please/310188/1 "2010-06-03T15:39:40Z")

</div>

Hi,

I would like to thank everyone in advance for the help these forums and the people on them provide. Lots of great info!

I did a search for a problem I am having and cannot seem to find anything on it.

I am trying to save locally into the users computer with a Shared Object, but have multiple variables to change and save using a function. I cannot seem to get the syntax correct for it to work.

This is suppose to check the variable names \_root.levelcompletestatus011 through \_root.levelcompletestatus070 and if any of them equal 4, then change them to 0 and save to the local file.

Here is what I have so far:

function templockopen() {  
for (i=11; i\<71; i++) {  
if (eval("\_root.levelcompletestatus0"+i) == 4) {  
this[“levelcompletestatus0”+String(i)] = 0;  
this[“savefile.data.level0”+String(i)] = eval("\_root.levelcompletestatus0"+i);  
\_root.savefile.flush();  
trace(eval("\_root.levelcompletestatus0"+i))  
}

```
}

```

}

I appreciate any help you can give.

Thank you,  
[tcooley2003@yahoo.com](mailto:tcooley2003@yahoo.com)
