# Forloop and MovieClipLoader

**URL:** <https://forum.kirupa.com/t/forloop-and-moviecliploader/264178>\
**Category:** Uncategorized\
**Created:** [June 23, 2008, 7:35pm UTC](https://forum.kirupa.com/t/forloop-and-moviecliploader/264178 "2008-06-23T19:35:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![geestring](https://avatars.discourse-cdn.com/v4/letter/g/e19b73/32.png) [@geestring](https://forum.kirupa.com/u/geestring)\
**Post date:** [June 23, 2008, 7:35pm UTC](https://forum.kirupa.com/t/forloop-and-moviecliploader/264178/1 "2008-06-23T19:35:03Z")

</div>

for (var s = 0; s\<matFabrics.length; s++) {  
var currentSubPicture = matFabrics[s];  
var currentSubThumb = materialSection.createEmptyMovieClip(“subthumb\_mc”+s, s);  
var containerSubThumb = currentSubThumb.createEmptyMovieClip(“subcontainer”+s, s);  
currentSubThumb.attachMovie(“subthumb\_bg\_mc”,“subthumb\_bg\_mc”+s,s-1);  
if (s\<4) {  
destThumbX = s_thumb\_space;  
destThumbY = 0_thumb\_rowspace;  
} else if (3\<s and s\<8) {  
destThumbX = (s_thumb\_space)-(4_thumb\_space);  
destThumbY = 1_thumb\_rowspace;  
} else if (7\<s and s\<12) {  
destThumbX = (s_thumb\_space)-(8_thumb\_space);  
destThumbY = 2_thumb\_rowspace;  
} else if (11\<s and s\<16) {  
destThumbX = (s_thumb\_space)-(12_thumb\_space);  
destThumbY = 3_thumb\_rowspace;  
} else if (15\<s and s\<20) {  
destThumbX = (s_thumb\_space)-(16_thumb\_space);  
destThumbY = 4_thumb\_rowspace;  
}  
easeName(destThumbX,destThumbY,currentSubThumb);

```
	var mcl:MovieClipLoader = new MovieClipLoader();
	mcl.loadClip(currentSubPicture.attributes.thumb,containerSubThumb);
	var container:Object = new Object();
	mcl.addListener(container);

	container.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
		
		var ld = target.attachMovie("temp_loader","temp_loader"+s,s+2);
		ld._xscale = 10;
		ld._yscale = 10;
		
	};
	container.onLoadInit = function(target:MovieClip) {
		target._x = target._x-(target._width/2);
		target._y = target._y-(target._height/2);
	};

```

basically this does a fine job of loading in my thumbs… Now I want to had a little preloader mc on every thumb as they load. what i have now doesnt work. I guess the only variable that is taken is target. Which is the container.

Do I put a forloop in the loadProgress and somehow count how many containers there are?

---

<div class="post-metadata">

**Author:** ![geestring](https://avatars.discourse-cdn.com/v4/letter/g/e19b73/32.png) [@geestring](https://forum.kirupa.com/u/geestring)\
**Post date:** [June 24, 2008, 1:18am UTC](https://forum.kirupa.com/t/forloop-and-moviecliploader/264178/2 "2008-06-24T01:18:44Z")

</div>

this is a newer part.  
container.currentThumb = currentSubThumb;  
container.trackS = s;//stores the s value in container  
container.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {

```
		var loader = this.currentThumb.attachMovie("temp_loader", "temp_loader"+this.trackS, this.trackS+1);
		loader._xscale = 10;
		loader._yscale = 10;

		if (bytesLoaded == bytesTotal) {
			removeMovieClip(loader);
			trace(loader);
		}
	};

```

however it looks to me that only the first thumb is affected by it… any ideas?

---

<div class="post-metadata">

**Author:** ![geestring](https://avatars.discourse-cdn.com/v4/letter/g/e19b73/32.png) [@geestring](https://forum.kirupa.com/u/geestring)\
**Post date:** [June 24, 2008, 1:28am UTC](https://forum.kirupa.com/t/forloop-and-moviecliploader/264178/3 "2008-06-24T01:28:48Z")

</div>

ill just give you a link to see for yourselves.  
try and max out your upload an download. then run it  
[http://adamgee.ca/hazelton/content-test.html](http://adamgee.ca/hazelton/content-test.html)

it doesnt affect all thumbs, but in a weird way. some thumbs arent some are. One at a time. its all random.

try a few times. sometimes it doesnt show up at all.

---

<div class="post-metadata">

**Author:** ![randomagain](https://avatars.discourse-cdn.com/v4/letter/r/35a633/32.png) [@randomagain](https://forum.kirupa.com/u/randomagain)\
**Post date:** [June 24, 2008, 8:24am UTC](https://forum.kirupa.com/t/forloop-and-moviecliploader/264178/4 "2008-06-24T08:24:34Z")

</div>

_my brain is rotting_

you need a loaderBar which recognizes only the targetMC its assigned to

…

I think you may stick a checking for loop in the loadProgress of the loadClip

which essentially sends off the data specific for targetMC to the loadBar element

_shrugs_
