I wrote the following code to load a JPEG into a thumbnail, show a loading bar, then format the image. The problem is that no matter whether I run the script in Flash, in Flash testing mode on a 56k modem, or in my browser, the onEnterFrame goes through 2 and only 2 frames.
In the first frame there are no thumbnail images and the loading bar is 1 px wide, telling me its in the “zero percent” block below. The second frame has the images loaded and the load bar disappears. The problem is that there are about 3 seconds between the 1st frame and 2nd frame…but I’m running a 32 fps flash movie…why is this happening?
Shouldn’t a large number of frames execute between that 1st and 2nd frame I mentioned, and show a progression of the load bar, rather than go from zero to full?
In case it matters, I have traced the bytesTotal and bytesLoaded for both frames
Frame 1: 0 bytes loaded and 0 bytes total
Frame 2: 1691188 bytes loaded and 1691188 bytes total
-thisThumbnail is a reference to my current thumbnail object
-thisThumbnail.thumbContainer is the movieClip within thisThumbnail
-I load a JPEG into thisThumbnail.thumbContainer.image
formatAndLoad = function(thisThumbnail) {
//attach loadBar
thisThumbnail.loadBar = thisThumbnail.thumbContainer.attachMovie
("thumbLoadBar","loadBar",99);
fullLoadBar = thisThumbnail.loadBar._width;//record full loadBar width
thisThumbnail.thumbContainer.onEnterFrame = function() {
if((this.image.getBytesLoaded() == this.image.getBytesTotal())&&
(this.image.getBytesLoaded() > 0)) {
//image is loaded
thisThumbnail.loadBar._alpha = 0;
thisThumbnail.formatIMG(106, 106);//this just scales the JPEG
delete this.onEnterFrame;
}else{
if(this.image.getBytesLoaded() == 0) {
//zero percent
thisThumbnail.loadBar._width = 1;
}else{
percent = this.image.getBytesLoaded()/this.image.getBytesTotal();
thisThumbnail.loadBar._width = fullLoadBar * percent;
}
}
}
}