# attachMovie addressing in a for loop

**URL:** <https://forum.kirupa.com/t/attachmovie-addressing-in-a-for-loop/264393>\
**Category:** flash\
**Created:** [June 25, 2008, 6:42pm UTC](https://forum.kirupa.com/t/attachmovie-addressing-in-a-for-loop/264393 "2008-06-25T18:42:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wolcotter](https://avatars.discourse-cdn.com/v4/letter/w/6bbea6/32.png) [@wolcotter](https://forum.kirupa.com/u/wolcotter)\
**Post date:** [June 25, 2008, 6:42pm UTC](https://forum.kirupa.com/t/attachmovie-addressing-in-a-for-loop/264393/1 "2008-06-25T18:42:47Z")

</div>

Looking to convert the following attachMovie actions to a for loop. I get an error message running the following loop and I’m not sure what the correct syntax is. Takers?

From this:

this.mc01.attachMovie(“timebar01”,“timebar01”,5,{\_x:0, \_y:450});  
this.mc02.attachMovie(“timebar02”,“timebar02”,6,{\_x:0, \_y:450});  
this.mc03.attachMovie(“timebar03”,“timebar03”,7,{\_x:0, \_y:450});  
this.mc04.attachMovie(“timebar04”,“timebar04”,8,{\_x:0, \_y:450});

To this:

for (var i = 1; i \< 5; i++) {  
this.[“mc0”+i].attachMovie(“timebar0”+i,“timebar0”+[i+4], i, {\_x:0, \_y:450});  
}

TIA

---

<div class="post-metadata">

**Author:** ![sparkdemon](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sparkdemon](https://forum.kirupa.com/u/sparkdemon)\
**Post date:** [June 25, 2008, 10:19pm UTC](https://forum.kirupa.com/t/attachmovie-addressing-in-a-for-loop/264393/2 "2008-06-25T22:19:42Z")

</div>

try this:

for (var i = 1; i \< 5; i++)  
{  
this[“mc0”+i].attachMovie(“timebar0”+i,“timebar0”+(i+4), i, {\_x:0, \_y:450});  
}
