# For loops and arrays

**URL:** https://forum.kirupa.com/t/for-loops-and-arrays/316419
**Category:** Uncategorized
**Created:** [November 20, 2010, 9:05pm UTC](https://forum.kirupa.com/t/for-loops-and-arrays/316419 "2010-11-20T21:05:22Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![bonassus](https://avatars.discourse-cdn.com/v4/letter/b/ea5d25/32.png) [@bonassus](https://forum.kirupa.com/u/bonassus)
#### Post date: [November 20, 2010, 9:05pm UTC](https://forum.kirupa.com/t/for-loops-and-arrays/316419/1 "2010-11-20T21:05:22Z")

</div>

I’m new to programing.  
I’m trying to use a for loop to repeat the code below 8 times with numbers 1 through 8. As in object1, object2 etc.

```auto
object1 = new Sprite;
object1.x = 120;
object1.y = 120;
object1.buttonMode = true;
addChild(object1);

```

I don’t quite have the hang of using for loops yet. this doesn’t work

```auto
for(var i = 0; i < 8; i++){
object+i = new Sprite;
object+i.x = 120;
object+i.y = 120;
object+i.buttonMode = true;
addChild(object+i);
        }

```

can someone show me how to do this.

thanks
