# Changing a variable name

**URL:** <https://forum.kirupa.com/t/changing-a-variable-name/272222>\
**Category:** Uncategorized\
**Created:** [October 3, 2008, 2:36am UTC](https://forum.kirupa.com/t/changing-a-variable-name/272222 "2008-10-03T02:36:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fydus](https://avatars.discourse-cdn.com/v4/letter/f/8c91f0/32.png) [@Fydus](https://forum.kirupa.com/u/Fydus)\
**Post date:** [October 3, 2008, 2:36am UTC](https://forum.kirupa.com/t/changing-a-variable-name/272222/1 "2008-10-03T02:36:19Z")

</div>

Hey, I’m currently working on making a side-scroller and came across a problem when scrolling tiles.

I use an object to hold information and an mc  
Is there anyway I can change the variable name of an object or movie-clip?

Reason: I want to be able to access certain tiles from the scroller quickly by using the x&y coordinates of the tile.

ie:

```auto

var obj:Object = new Object();
for(i = 0; i != 10; i++) //x-coord
    for(j = 0; j != 10; j++) //y-coord
        obj["_"+i+"_"+j] = new MovieClip(); //accessing obj's mc using coordinates

```

Then later when I want to move a particular movie-clip over to represent a new tile on the screen, I just move a previous unneeded tile over so that I won’t have to delete the old one and create a new movie-clip and fill it with information. But the problem comes in this. I can’t change the obj name to anything else when it becomes a new tile with coordinates i and j, I can’t access it by going obj["_"+i+"_"+j] anymore. I have to use it’s old name obj["_"+oldI+"_"+oldJ].

Does anyone have a way around this? Maybe my way of storing variables is bad?

I hope my explanation was clear.

Thanks much,  
Fydus
