# Need some help with this code pls

**URL:** <https://forum.kirupa.com/t/need-some-help-with-this-code-pls/209680>\
**Category:** flash\
**Created:** [December 11, 2006, 3:39pm UTC](https://forum.kirupa.com/t/need-some-help-with-this-code-pls/209680 "2006-12-11T15:39:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![G1NG](https://avatars.discourse-cdn.com/v4/letter/g/bc8723/32.png) [@G1NG](https://forum.kirupa.com/u/G1NG)\
**Post date:** [December 11, 2006, 3:39pm UTC](https://forum.kirupa.com/t/need-some-help-with-this-code-pls/209680/1 "2006-12-11T15:39:37Z")

</div>

Hi,

I m trying to build a dynamic thumbnail loader. I managed to load the thumbnails and distribute them into rows according to the stage width. Though, the on press function is not activated since the thumbnails are not really loaded till that function is called. I tried adding several preloading methods but [Type Function] is outputted.

Can anyone help pls?

Thanks

//Intial Values  
xCoordinate = 20;  
yCoordinate = 20;  
x\_coordinate = xCoordinate;  
y\_coordinate = yCoordinate;  
thumbSpace = 5;  
image\_folder = “thumbs/”;  
filetype = “.jpg”;  
totalImages = 12;  
thumbHeight = 50;  
thumbWidth = 50;

//Actual Stage area  
stageWidth = Stage.width - (x\_coordinate_2);  
stageHeight = Stage.height - (y\_coordinate_2);  
//How many thumbs fit in a row  
fittedThumbs = Math.floor(stageWidth/(thumbWidth + thumbSpace));

//Create MovieClips and load thumbs in them  
for(i=1;i\<=totalImages;i++){  
createEmptyMovieClip(“thumb” add i, i);  
theThumb = eval(“thumb” add i);

//Listener  
//thumbLoader = new MovieClipLoader();  
//thumbListener = new Object();  
[//thumbListener.onLoadComplete](https://thumbListener.onLoadComplete) = function(theThumb){  
// trace(“Loaded”);  
//}

theThumb.\_x = x\_coordinate;  
theThumb.\_y = y\_coordinate;  
theThumb.loadMovie(image\_folder + i + filetype);

//On events  
theThumb.onLoad = function(){  
trace(“pressed”);  
}

//Add a space between a thumb and another  
x\_coordinate += thumbWidth + thumbSpace;

//Create rows  
if(totalImages\>=fittedThumbs){  
if(i==fittedThumbs){  
x\_coordinate = xCoordinate;  
y\_coordinate += thumbHeight + thumbSpace;  
}  
if(i==fittedThumbs_2){  
x\_coordinate = xCoordinate;  
y\_coordinate += thumbHeight + thumbSpace;  
}  
if(i==fittedThumbs_3){  
x\_coordinate = xCoordinate;  
y\_coordinate += thumbHeight + thumbSpace;  
}  
}  
trace(thumb1.getBytesLoaded);  
}

trace(stageHeight);
