Preloader

Hello. I am working on a photo gallery and I am trying to make a preloader. But something is wrong.
I am using this code:

function startLoading(whichImage) {
_root.onEnterFrame = function() {
infoLoaded = imageLoader.getBytesLoaded();
infoTotal = imageLoader.getBytesTotal();
percentage = Math.floor(infoLoaded/infoTotal*100);
infoField.text = percentage + " %";
if (percentage >= 100) {
loadMovie(whichImage, “imageLoader”);
delete this.onEnterFrame;
infoField._visible = false;
}
};
}

The problem is that infoField is showing only 0% and 100%.
Could someone guide me to the right way?
And for example if I have an xml file and load thumbnails from it how do I show the progress for each thumbnail or in a text box something like this: 5/10 loaded.
Thank you.