# Trying to run For loop to do multiple attachmovies

**URL:** https://forum.kirupa.com/t/trying-to-run-for-loop-to-do-multiple-attachmovies/204039
**Category:** flash
**Created:** [October 16, 2006, 5:08pm UTC](https://forum.kirupa.com/t/trying-to-run-for-loop-to-do-multiple-attachmovies/204039 "2006-10-16T17:08:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![livin41](https://avatars.discourse-cdn.com/v4/letter/l/91b2a8/32.png) [@livin41](https://forum.kirupa.com/u/livin41)
#### Post date: [October 16, 2006, 5:08pm UTC](https://forum.kirupa.com/t/trying-to-run-for-loop-to-do-multiple-attachmovies/204039/1 "2006-10-16T17:08:18Z")

</div>

Please help me…:red: as u can see im burning up…

I have 20 default movieclips (pictures) which i am trying to load into other movieclips (using attachmovie) dynamically through a textfile. Each 1 of the movieclips has a linkage identifier (named from 1 - 20 numerically). Im trying to use a text file to dynamically change the placing of the pictures (default movieclips) as well as duplicate where necessary. i can load the pictures but the For loop just doesnt work… Please help me as iv been at this all day. here is my code… i have a textfile called front\_img.txt and the variables are named like this: 1img=9&2img=1&3img=12&4img=15&5img=2… etc…

loadText = new LoadVars();  
loadText.load(“front\_img.txt”);  
loadText.onLoad = function() {

```
            var i:Number;

```

for (i = 1; i \<= 20; i++) {  
bob = “”;  
bob = this[i+“img”];  
trace(i);  
trace(bob);  
if (bob== “1”) {  
\_root[i+“team\_mc”].attachMovie(1,“newResetButton”+i,1);  
//trace(i);  
}else if(bob== 2) {  
\_root[i+“team\_mc”].attachMovie(2,“newResetButton”+i,1);  
}else if (bob== 3) {  
\_root[i+“team\_mc”].attachMovie(3,“newResetButton”+i,1);  
}else if (bob== 4) {  
\_root[i+“team\_mc”].attachMovie(4,“newResetButton”+i,1);  
}else if (bob== “5”) {  
\_root[i+“team\_mc”].attachMovie(5,“newResetButton”+i,1);  
}else if (bob== 6) {  
\_root[i+“team\_mc”].attachMovie(6,“newResetButton”+i,1);  
}else if (bob== 7) {  
\_root[i+“team\_mc”].attachMovie(7,“newResetButton”+i,1);  
}else if (bob== 8) {  
\_root[i+“team\_mc”].attachMovie(8,“newResetButton”+i,1);  
}else if (bob== 9) {  
\_root[i+“team\_mc”].attachMovie(9,“newResetButton”+i,1);  
}else if (bob== 10) {  
\_root[i+“team\_mc”].attachMovie(10,“newResetButton”+i,1);  
}else if (bob== 11) {  
\_root[i+“team\_mc”].attachMovie(11,“newResetButton”+i,1);  
}else if (bob== 12) {  
\_root[i+“team\_mc”].attachMovie(12,“newResetButton”+i,1);  
}else if (bob== 13) {  
\_root[i+“team\_mc”].attachMovie(13,“newResetButton”+i,1);  
}else if (bob== 14) {  
\_root[i+“team\_mc”].attachMovie(14,“newResetButton”+i,1);  
}else if (bob== 15) {  
\_root[i+“team\_mc”].attachMovie(15,“newResetButton”+i,1);  
}else if (bob== 16) {  
\_root[i+“team\_mc”].attachMovie(16,“newResetButton”+i,1);  
}else if (bob== 17) {  
\_root[i+“team\_mc”].attachMovie(17,“newResetButton”+i,1);  
}else if (bob== 18) {  
\_root[i+“team\_mc”].attachMovie(18,“newResetButton”+i,1);  
}else if (bob== 19) {  
\_root[i+“team\_mc”].attachMovie(19,“newResetButton”+i,1);  
}else if (bob== 20) {  
\_root[i+“team\_mc”].attachMovie(20,“newResetButton”+i,1);  
}

}  
};

If there is a better way please tell me.
