# For (i=0;i=done;i++) {messed up}

**URL:** https://forum.kirupa.com/t/for-i-0-i-done-i-messed-up/64914
**Category:** flash
**Created:** [September 21, 2004, 10:18am UTC](https://forum.kirupa.com/t/for-i-0-i-done-i-messed-up/64914 "2004-09-21T10:18:15Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Phat7](https://avatars.discourse-cdn.com/v4/letter/p/6de8d8/32.png) [@Phat7](https://forum.kirupa.com/u/Phat7)
#### Post date: [September 21, 2004, 10:18am UTC](https://forum.kirupa.com/t/for-i-0-i-done-i-messed-up/64914/1 "2004-09-21T10:18:15Z")

</div>

I have two “for” statements in a row in one frame, which duplicate two different movies. First one creates 7 copies of one movie and the second one creates 30 copies of another movie. When I write the first one only it duplicates 7 movies, works fine. When i write the second one it works properly but the first one stops working. The question is:

Why:q:

Here’s the code if needed:

```auto
weekdays = new Array ("Su","Mo","Tu","We","Th","Fr","Sa")
now = new Date();
weekd._x = -25;
ox = weekd._x * -1;
days._x = -25;

for (i = 0;i<weekdays.length;i++) {
	_root.weekd.duplicateMovieClip("weekd"+i,i);
	_root["weekd"+i]._x = ox * i + 30;
}
for (j = 1;j<31;j++) {
	_root.days.duplicateMovieClip("days"+j,j);
	_root["days"+j]._x = ox2 * j + 30;
}

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 21, 2004, 10:55am UTC](https://forum.kirupa.com/t/for-i-0-i-done-i-messed-up/64914/2 "2004-09-21T10:55:02Z")

</div>

because you put movieclips in the same depth

it goes like:

1st “for” creates movies on depths 1, 2, 3, 4, 5, … and so on

and the 2nd “for” creates movies on depths 1, 2, 3, 4, 5 as well

it collides with each other and the old one is being replaced with new one

simple

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 21, 2004, 10:56am UTC](https://forum.kirupa.com/t/for-i-0-i-done-i-messed-up/64914/3 "2004-09-21T10:56:03Z")

</div>

[AS]  
weekdays = new Array (“Su”,“Mo”,“Tu”,“We”,“Th”,“Fr”,“Sa”)  
now = new Date();  
weekd.\_x = -25;  
ox = weekd.\_x \* -1;  
days.\_x = -25;

for (i = 0;i\<weekdays.length;i++) {  
\_root.weekd.duplicateMovieClip(“weekd”+i,i);  
\_root[“weekd”+i].\_x = ox \* i + 30;  
}  
for (j = 1;j\<31;j++) {  
\_root.days.duplicateMovieClip(“days”+j,j + weekdays.length);  
\_root[“days”+j].\_x = ox2 \* j + 30;  
}  
[/AS]

this way the weekday MCs will take up depths 0 - 6 and days will take up 7 - 36.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 21, 2004, 11:21am UTC](https://forum.kirupa.com/t/for-i-0-i-done-i-messed-up/64914/4 "2004-09-21T11:21:31Z")

</div>

Duh! Thanx guys :thumb:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 21, 2004, 11:38am UTC](https://forum.kirupa.com/t/for-i-0-i-done-i-messed-up/64914/5 "2004-09-21T11:38:57Z")

</div>

n/p
