Iso The Ultimate Final Preloader Solution!

Okay, I’ve looked all over the internet, searched forums far and wide (including kirupa), and still cannot find a working answer to how to preload media (image, swf, or quicktime) into a flash movie clip, using feedback (also NOT in the first frame of the movie). I’ve experimented with many techniques, to no avail. It can be done, I know that, and I also know I’m not the only one who runs into this problem. So I’m hoping with this thread to generate a final answer to a common question. I’m at the mercy of the experts of this forum.

Here’s what I have now:

A flash file, an empty movie clip labelled ‘container’, and a target path to an image stored in a variable ‘myImage’

frame 8 script: loadMovie(myImage, _root.conainer);

frame 9: blank keyframe.

frame 10 script:

var bytesL = _root.container.getBytesLoaded();
var bytesT = _root.container.getBytesTotal();

if(bytesL==bytesT) {
play();
} else {
mediaLoadPercent = Math.round((bytesL/bytesT)*100)
gotoAndPlay(_currentframe - 1);
}

seems simple and logical, yet it doesn’t work. If anyone can explain this and knows how to make it work, I will not only send the solution to the multitude of souls who are looking for the same explaination, i will send you a cookie :wink:

cheers,

CommanderCool

“frame 8 script: loadMovie(myImage, _root.conainer);”
if that’s copy paste, then there’s a “t” missing in container…
else: what doesn’t work, which part of your script?
did you try debugging with trace()?
can you post the fla?
what’s in “myImage” (trace that)/how does it get set?
etc…

Oh sweet memories of preloadertesting…

In my preloaders I use a check to confirm that bytesLoaded and bytesTotal are not = 0 (that’s what they are initially - however in your case where you let the moive roll two frames they should be !0)


if (bytesT != 0) {
   if(bytesL==bytesT) {
      play();
   }else {
      mediaLoadPercent = Math.round((bytesL/bytesT)*100)
      gotoAndPlay(_currentframe - 1);
   }
}

Are you aware that you’ll never see the preloader work while it is on your local computer (unless you use a bandwith limiter). This happened to me once where i thought I limited the speed using flash’s internal limiter - that won’t work!

yea, sorry, that’s a typo only in the message I just wrote. All the syntax in the flash file is correct. You can see what happens at www.rafaelmacho.com. When you click on an item, a picture loads, but doesn’t preload like it’s supposed to (using the beforementioned script) so it looks dumb.

i’ve traced the file, and the path is created and stored correctly. (the path is stored in a customized array, and is chosen by the clicked menu’s number).
i’ve traced the getBytesLoaded, and getBytesTotal values even, and indeed after the loadMovie command, the values change from 18 bytes to ca. 45000 or whatever, but there is no increment in between those values, which is what needs to happen in order for flash to know that the file isn’t totally loaded, and thus loops until it is. There is SOMEthing happening here thats wrong, I just can’t see it.

I had a similar thread going earlier, but I’ve refined my question a bit. There you can download the actual fla file and a sample image I’m using"

http://www.kirupaforum.com/forums/showthread.php?s=&threadid=24091

thanks for the help,

CommanderCool

colaBoy -

I think I’ve tried that one, but maybe not in conjunction with the final script i came up with (it sounds clever enough to be a solution though). I will let you know. And yeah, I know that localized media loads instantly, for some reason the streaming option in the flash played doesn’t work for preloaded media either (I mean it doesn’t show in the buffer graph) I’ve tried even setting the bandwidth to 0.2 kbps, but not much gained. The best way is for me to upload it in a reserve space on the net and the download it from a modem.

Also I’ve read that AOL’s browser doesn’t support loading of external media into flash files, does anyone know if there is any truth to this? (I don’t and will never use AOL again, but it is a concern)

peace,

CommanderCool

hmm - if you don’t get the increments - maybe this method works:


container.loadMovie("yourImage", 1);
_root.createEmptyMovieClip("looper", 100);
looper.onEnterFrame = function() {
	bytesL = container.getBytesLoaded();
	bytesT = container.getBytesTotal();
	if (bytesT>0) {
		_root.loadingBar._xscale = bytesL/bytesT*100;
		if (bytesL == bytesT) {
			this.onEnterFrame = null;
			this.removeMovieClip();
		}
	}
};

colaBoy - okay, I’ll give that a try too… btw I was thinking about the line you use (if BytesT > 0) or just in general to make sure that its loaded and larger than zero, but the problem is that even before the image is loaded using loadMovie, _root.container.getBytesTotal() will still return > 0, something between 4 and 18 bytes, as the vector is small, but larger than zero, so that line of code seems redundant almost, I guess. I can understand though that there might be a point right after the movie loads where the values are equal, but at only 0, 4 or 18, thus the playhead just passes right through the if-then statement… I’m going to try also using a setInterval method maybe. I’ll try your code first though and let you know how it goes. Thanks for your help.

cheers,

CommanderCool