Preload for pictures loaded from XML

i have a preloader that at the second frame i am getting the total bytes of all the pictures. which are located in a MC. i looped it so i would have the total bytes of all pictures in one variable.


for (var m:Number = 0; m<_parent.total; m++) {
 totalBytes = totalBytes+_root.contentMain["targetClip"+m].getBytesTotal();
}

i cant figure out how to do the rest. i added on the third frame this:


totalBytesLoaded = _root.contentMain["targetClip"+i].getBytesLoaded();
thePer = int((100*totalBytesLoaded)/totalBytes);

thePer represents the precantage of the loaded bytes
and on the last frame:


if (thePer > 99) {
 _parent.play();
} else {
 gotoAndPlay(3);
 i++;
}

and thePer goes up to 15 and back to 0.
i tried all kind of things that is the last unsucsess
can anybody help me with this?