# For loop & Mc problem...difficult

**URL:** <https://forum.kirupa.com/t/for-loop-mc-problem-difficult/27999>\
**Category:** flash\
**Created:** [August 8, 2003, 6:48pm UTC](https://forum.kirupa.com/t/for-loop-mc-problem-difficult/27999 "2003-08-08T18:48:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![7of9](https://avatars.discourse-cdn.com/v4/letter/7/c89c15/32.png) [@7of9](https://forum.kirupa.com/u/7of9)\
**Post date:** [August 8, 2003, 6:48pm UTC](https://forum.kirupa.com/t/for-loop-mc-problem-difficult/27999/1 "2003-08-08T18:48:46Z")

</div>

Can some help me with this for loop & Mc problem…I have no idea why the  
below code works without a for loop, but If I but the below code  
in a for loop it doesn’t work.

Note 2 things: The i variable values 0 and 1. The ContainerMc Mc name when i=0  
and ContainerMcx Mc name when i=1. If I use the ContainerMc Mc name for both  
iterations(i=0 & i=1) it will not work.

Look at the for loop version it only works  
for the first i=o itertion and doesn’t work for i=1, but no syntax error.

```
  var i=0
   ThumbNailMc= _root.McHolder["ColorMc" + McColors*]; 
   ContainerMc= ThumbNailMc.createEmptyMovieClip("PicContainer"+i,i*7656);
   ContainerMc.loadMovie("pict.jpg");
  
   var bytes_loaded= Math.round(ContainerMc.getBytesLoaded());
   var bytes_total= Math.round(ContainerMc.getBytesTotal());
   var getPercent= bytes_loaded/bytes_total;
   
   ThumbNailMc.onEnterFrame= function()
    {
      if (bytes_loaded &gt;1 && bytes_loaded &gt; bytes_total-10 && ContainerMc._width &gt; 0 && getPercent &gt;= 1)
  	   {
		ContainerMc.ResizeImage(45,20);
		ContainerMc._x= (-1 * (ContainerMc._width/2)) ;
		ContainerMc._y= -1 * (ContainerMc._height/2);
		ContainerMc._alpha= 100;
		trace(this + "this")
		delete this.onEnterFrame;
	   }
	  else
	   {
		 bytes_loaded= Math.round(ContainerMc.getBytesLoaded());
	     bytes_total= Math.round(ContainerMc.getBytesTotal());
	     getPercent= bytes_loaded/bytes_total; 			
	   }
	}//thumbnail...
	
	
       i=1
   ThumbNailMc= _root.McHolder["ColorMc" + McColors*]; 
   ContainerMcx= ThumbNailMc.createEmptyMovieClip("PicContainer"+i,i*7656);
   ContainerMcx.loadMovie("pict.jpg");
  
   var bytes_loaded= Math.round(ContainerMcx.getBytesLoaded());
   var bytes_total= Math.round(ContainerMcx.getBytesTotal());
   var getPercent= bytes_loaded/bytes_total;
   
   ThumbNailMc.onEnterFrame= function()
    {
      if (bytes_loaded &gt;1 && bytes_loaded &gt; bytes_total-10 && ContainerMcx._width &gt; 0 && getPercent &gt;= 1)
  	   {
		ContainerMcx.ResizeImage(45,20);
		ContainerMcx._x= (-1 * (ContainerMcx._width/2)) ;
		ContainerMcx._y= -1 * (ContainerMcx._height/2);
		ContainerMcx._alpha= 100;
		trace(this + "this")
		delete this.onEnterFrame;
	   }
	  else
	   {
		 bytes_loaded= Math.round(ContainerMcx.getBytesLoaded());
	     bytes_total= Math.round(ContainerMcx.getBytesTotal());
	     getPercent= bytes_loaded/bytes_total; 			
	   }
	}//thumbnail..

```

//For loop version: Note using same ContainerMc name only works for the  
first iteration(i=0) not when i=1. Why???

for (i=0; i \<= 0; i++)  
{  
ThumbNailMc= \_root.McHolder[“ColorMc” + McColors\*];  
ContainerMc= ThumbNailMc.createEmptyMovieClip(“PicContainer”,i);  
ContainerMc.loadMovie(“pict0002.jpg”);

```
   var bytes_loaded= Math.round(ContainerMc.getBytesLoaded());
   var bytes_total= Math.round(ContainerMc.getBytesTotal());
   var getPercent= bytes_loaded/bytes_total;
   
   ThumbNailMc.onEnterFrame= function()
    {
      if (bytes_loaded &gt;1 && bytes_loaded &gt; bytes_total-10 && ContainerMc._width &gt; 0 && getPercent &gt;= 1)
  	   {
		ContainerMc.ResizeImage(45,20);
		ContainerMc._x= (-1 * (ContainerMc._width/2)) ;
		ContainerMc._y= -1 * (ContainerMc._height/2);
		ContainerMc._alpha= 100;
		trace(this + "this")
		delete this.onEnterFrame;
	   }
	  else
	   {
		 bytes_loaded= Math.round(ContainerMc.getBytesLoaded());
	     bytes_total= Math.round(ContainerMc.getBytesTotal());
	     getPercent= bytes_loaded/bytes_total; 			
	   }
	}//thumbnail...	

```

} //for

---

<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 8, 2003, 7:21pm UTC](https://forum.kirupa.com/t/for-loop-mc-problem-difficult/27999/2 "2003-08-08T19:21:35Z")

</div>

because  
for (i=0; i \<= 0; i++)  
will never be run with i=1, simply!  
(2nd loop, i==1, so i\<=0 evaluates to false and the loop breaks)  
use  
for (i=0; i \<2; i++)

---

<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 8, 2003, 8:16pm UTC](https://forum.kirupa.com/t/for-loop-mc-problem-difficult/27999/3 "2003-08-08T20:16:33Z")

</div>

It was a typo, i put the 2 in…the question still stands.
