# For in loop question

**URL:** <https://forum.kirupa.com/t/for-in-loop-question/62302>\
**Category:** Uncategorized\
**Created:** [August 26, 2004, 5:58pm UTC](https://forum.kirupa.com/t/for-in-loop-question/62302 "2004-08-26T17:58:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fugzi](https://avatars.discourse-cdn.com/v4/letter/f/c67d28/32.png) [@fugzi](https://forum.kirupa.com/u/fugzi)\
**Post date:** [August 26, 2004, 5:58pm UTC](https://forum.kirupa.com/t/for-in-loop-question/62302/1 "2004-08-26T17:58:44Z")

</div>

Hi Im using a for in loop to grab the names of my mc on the \_root timeline and push() them into an array named bricks. i then use a prototype function fade them in one at a time. The problem is that it only works to a piont and then stops.

I thought posible causes could be the time it takes to build the array as i do have 713 mc on my timeline.

this is my code i tried attaching the fla but its to big

fadespeed = 9;  
function init(){  
brick = new Array();  
for(var prop in \_root){  
if(typeof \_root[prop] ==“movieclip”){  
brick.push(\_root[prop]);  
}  
for( var i = 0; i\<brick.length; i++) {  
brick\*.\_alpha = 0;  
brick\*.id = i;  
}  
brick[0].fade();  
}  
}  
MovieClip.prototype.fade = function() {  
this.go = true;  
this.onEnterFrame = function() {  
this.\_alpha += fadespeed;  
if (this.go) {  
if (this.\_alpha\<50) {  
this.go = false;  
brick[this.id+1].fade();  
}  
}  
if (this.\_alpha\>=100) {  
delete this.onEnterFrame;  
}  
};  
};  
init();

thank you

---

<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:** [August 26, 2004, 6:57pm UTC](https://forum.kirupa.com/t/for-in-loop-question/62302/2 "2004-08-26T18:57:08Z")

</div>

> [@fugzi](#):
>
> Hi Im using a for in loop to grab the names of my mc on the \_root timeline and push() them into an array named bricks. i then use a prototype function fade them in one at a time. The problem is that it only works to a piont and then stops.
> 
> I thought posible causes could be the time it takes to build the array as i do have 713 mc on my timeline.
> 
> this is my code i tried attaching the fla but its to big
> 
> fadespeed = 9;  
> function init(){  
> brick = new Array();  
> for(var prop in \_root){  
> if(typeof \_root[prop] ==“movieclip”){  
> brick.push(\_root[prop]);  
> }  
> for( var i = 0; i\<brick.length; i++) {  
> brick\*.\_alpha = 0;  
> brick\*.id = i;  
> }  
> brick[0].fade();  
> }  
> }  
> MovieClip.prototype.fade = function() {  
> this.go = true;  
> this.onEnterFrame = function() {  
> this.\_alpha += fadespeed;  
> if (this.go) {  
> if (this.\_alpha\<50) {  
> this.go = false;  
> brick[this.id+1].fade();  
> }  
> }  
> if (this.\_alpha\>=100) {  
> delete this.onEnterFrame;  
> }  
> };  
> };  
> init();
> 
> thank you

I don`t think that there is anything wrong with your code,its just too much to do. I tried this which is basically the same  
brick = ;  
fadespeed = 2;  
for (var i = 0; i\<100; i++) {  
myclip = attachmovie(“mc”, “mc”+i, i);  
myclip.\_x = random(700);  
myclip.\_y = random(500);  
myclip.id = i;  
myclip.\_alpha = 0;  
brick.push(myclip);  
}  
MovieClip.prototype.fade = function() {  
this.go = true;  
this.onEnterFrame = function() {  
this.\_alpha += fadespeed;  
if (this.go) {  
if (this.\_alpha\<50) {  
this.go = false;  
brick[this.id+1].fade();  
}  
}  
if (this.\_alpha\>=100) {  
delete this.onEnterFrame;  
}  
};  
};  
brick[0].fade();

worked fine for 100 but broke down for 700.Varying transparency is really hard on processor too

---

<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:** [August 26, 2004, 7:14pm UTC](https://forum.kirupa.com/t/for-in-loop-question/62302/3 "2004-08-26T19:14:17Z")

</div>

I thought this might be the case cheers for your help looks like i will have to program the array my self odear
