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

Good points. The only reason I can come up with for why getBytesLoaded works the way it does is…magic. At least that’s my reasoning behind half of my AS coding :slight_smile:

I’ll look into it again in a few days when I have some free time, and I may make an addendum later on. Seriously, the reason why I decided to keep onEnterFrame as opposed to delete it is that it really doesn’t do any computing. It just cycles through. My CPU usage is 0% when just viewing the animation and about 3% when changing pcitures.

So, yes, it would be better for me to kill the enterFrame from running needlessly, but I was simply too lazy to implement an optimization that probably wouldn’t affect the final product.

:sailor:

Well gimme some of that magic, because it’s not working in my application. :smiley: