# How to write 'for' loop for this?

**URL:** <https://forum.kirupa.com/t/how-to-write-for-loop-for-this/39686>\
**Category:** Uncategorized\
**Created:** [January 9, 2004, 9:55pm UTC](https://forum.kirupa.com/t/how-to-write-for-loop-for-this/39686 "2004-01-09T21:55:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lunatic](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@lunatic](https://forum.kirupa.com/u/lunatic)\
**Post date:** [January 9, 2004, 9:55pm UTC](https://forum.kirupa.com/t/how-to-write-for-loop-for-this/39686/1 "2004-01-09T21:55:32Z")

</div>

And in the meantime here’s something else . . .

I have an image that I have sliced into squares of equal size (200 x 200 pixels) using the slice tool in Fireworks. I would like to load each square (“tile”) into it’s own movie clip. The MCs are to be dynamically created on the fly. Basically I’ve got 3 rows and four columns. This is the code I have so far but I’m thinking there must be a way to write a for loop for this:

[AS]  
// Create tile MCs  
this.createEmptyMovieClip(“r1c1”, 1);  
r1c1.\_x = 0;  
r1c1.\_y = 0;  
r1c1.loadMovie(“test\_slices/r1\_c1.jpg”);  
this.createEmptyMovieClip(“r1c2”, 2);  
r1c2.\_x = 200;  
r1c2.\_y = 0  
r1c2.loadMovie(“test\_slices/r1\_c2.jpg”);  
this.createEmptyMovieClip(“r1c3”, 3);  
r1c3.\_x = 400;  
r1c3.\_y = 0  
r1c3.loadMovie(“test\_slices/r1\_c3.jpg”);  
this.createEmptyMovieClip(“r1c4”, 4);  
r1c4.\_x = 600;  
r1c4.\_y = 0  
r1c4.loadMovie(“test\_slices/r1\_c4.jpg”);  
this.createEmptyMovieClip(“r2c1”, 5);  
r2c1.loadMovie(“test\_slices/r2\_c1.jpg”);  
r2c1.\_x = 0;  
r2c1.\_y = 200;  
this.createEmptyMovieClip(“r2c2”, 6);  
r2c2.\_x = 200;  
r2c2.\_y = 200;  
r2c2.loadMovie(“test\_slices/r2\_c2.jpg”);  
this.createEmptyMovieClip(“r2c3”, 7);  
r2c3.\_x = 400;  
r2c3.\_y = 200  
r2c3.loadMovie(“test\_slices/r2\_c3.jpg”);  
this.createEmptyMovieClip(“r2c4”, 8);  
r2c4.\_x = 600;  
r2c4.\_y = 200  
r2c4.loadMovie(“test\_slices/r2\_c4.jpg”);  
this.createEmptyMovieClip(“r3c1”, 9);  
r3c1.loadMovie(“test\_slices/r3\_c1.jpg”);  
r3c1.\_x = 0;  
r3c1.\_y = 400;  
this.createEmptyMovieClip(“r3c2”, 10);  
r3c2.\_x = 200;  
r3c2.\_y = 400;  
r3c2.loadMovie(“test\_slices/r3\_c2.jpg”);  
this.createEmptyMovieClip(“r3c3”, 11);  
r3c3.\_x = 400;  
r3c3.\_y = 400  
r3c3.loadMovie(“test\_slices/r3\_c3.jpg”);  
this.createEmptyMovieClip(“r3c4”, 12);  
r3c4.\_x = 600;  
r3c4.\_y = 400  
r3c4.loadMovie(“test\_slices/r3\_c4.jpg”);  
[/AS]

I tried:  
[AS]  
x=1  
for (i = 1; i\<4; i++) {  
for (j = 1; j\<5; j++) {  
this.createEmptyMovieClip(“r”+i+“c”+j, x)  
x++;  
}  
}  
[/AS]

but I have NO idead how to position the MCs or load them once they are created.

Any coding experts wanna take a stab at this one? :puzzled:

:bu:
