# Looping through instance names in a movieclip

**URL:** <https://forum.kirupa.com/t/looping-through-instance-names-in-a-movieclip/245743>\
**Category:** Uncategorized\
**Created:** [December 3, 2007, 5:01pm UTC](https://forum.kirupa.com/t/looping-through-instance-names-in-a-movieclip/245743 "2007-12-03T17:01:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![blackcoma](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@blackcoma](https://forum.kirupa.com/u/blackcoma)\
**Post date:** [December 3, 2007, 5:01pm UTC](https://forum.kirupa.com/t/looping-through-instance-names-in-a-movieclip/245743/1 "2007-12-03T17:01:47Z")

</div>

When I want to loop through instance names like: “tile1”, “tile2” etc.  
I use a code like this:

```php

for(var i=0;i<=10;i++)
{
   this["tile"+i]._x=300;
}

```

but when I put these MC’s inside an MC (which I’ve named: “ground”) for some reason this code:

```php

for(var i=0;i<=10;i++)
{
   _root.ground.this["tile"+i]._x=300;
}

```

doesn’t work.

WHY?

and another question, is there a way to loop through all the objects inside a movieclip without giving each one an instance name?

thanks.
