A Few XML Gallery Tutorial Questions

Hey hey,

First off I wanted to say good work on the tutorial by Kirupa. It’s been very helpful when I go to preload images I load into flash, thanks Kman.

Ok now onto questions…

Why do you use onEnterFrame instead of a setInterval at a very fast rate then clearing it after the image has successfully loaded, this would save more processor usage…

This is the block of code I am refering to:

this.onEnterFrame = function() {
 	filesize = picture.getBytesTotal();
 	loaded = picture.getBytesLoaded();
 	preloader._visible = true;
 	if (loaded != filesize) {
 		preloader.preload_bar._xscale = 100*loaded/filesize;
 	} else {
 		preloader._visible = false;
 		if (picture._alpha<100) {
 			picture._alpha += 10;
 		}
 	}
 };

And…how can you use getBytesTotal on an empty movieclip that’s not even fully loaded yet, I see it’s working but I don’t understand how. Does it update after some percentage loaded?

Last would be, why doesn’t he delete the onEnterFrame command after an image has loaded successfully, seems logical to save processes usage. :slight_smile:

Cheers,
-Neverrain