Same results?

I have a loop that is supposed to run a set of functions and output movieclips on a main movieclip. Each of these smaller movieclip is supposed to be a tile. The code below is supposed to make 50 movieClips each one from a different reference on the tileSheet. However it outputs 50 of the exact same movieclips.


var tDMax:int = 50;
//Start Get tiles
		function getTiles():void{
			tList.graphics.beginFill(0x000000);
			tList.graphics.drawRect(0, 0,tWidth * 5, tHeight * 10);
			tList.graphics.endFill();
			tList.x = 650;
			tList.y = 100;
			addChild(tList);
			displayT();
		}//End getTiles
		//Start get tile array
		function displayT():void{
			tileBi = new BitmapData(64, 32, true, 0x00000000);
			tDis = new Array();
			for(var tn:int = 0; tn < tDMax;tn++){
				tDis[ tn ] = new tile_mc;
				//tDis[ tn ].addEventListener(MouseEvent.CLICK, setTile);
				makeOut(tn);
			}
		}//End tile array
		//start Makeout (new DrawTile)
		function makeOut(tn:Number):void{
			var tileB:BitmapData = getTileImage (tn);
			var rect:Rectangle = new Rectangle(0, 0, tWidth, tHeight);
			var pt:Point = new Point(0,0);
			tileBi.copyPixels (tileB, rect, pt);
			tDis[ tn ].addChild(new Bitmap(tileBi));
			tList.addChild(tDis[ tn ]);
			tDis[ tn ].x = (tn % 5) * 64;
			tDis[ tn ].y = Math.floor((tn / 5)) * 32;
		}//Makeout
		//Get tile Image
		function getTileImage(tn:Number):BitmapData{
			var sheetT:BitmapData = tSheet;
			//number of columns in tilesheet
			var sheetColumnsT:int = tSheet.width / tWidth;
			//position where to take graphics from
			var colT:int = tn % sheetColumnsT;
			var rowT:int = Math.floor(tn / sheetColumnsT);
			//rectangle that defines tile graphics
			var rect:Rectangle = new Rectangle(colT * tWidth, rowT * tHeight, tWidth, tHeight);
			var pt:Point = new Point(0, 0);
			//get the tile graphics from tilesheet
			var tileB:BitmapData = new BitmapData(tWidth, tHeight, true, 0x00000000);
			tileB.copyPixels (sheetT, rect, pt);
			return tileB;
		}//End get image

Strange enough whatever I made tDMax which is supposed to be the limit for the loop, that’s what all the movieclips become. For example if I put it at 25, then all the movieClips become tiles from the bitmap sheet reference # 25.

That leads me to think that it’s not passing the variable to the functions correctly, and it’s only doing it once the loop finishes. But when I trace things like rowT and colT the references to the bitmap are correctly. And when I trade tn within the other functions that’s always correct also…