Groups | Blog | Home
all groups > flash actionscript > march 2004 >

flash actionscript : Preloader problem



tralfaz
3/28/2004 1:50:56 PM
[quoted text, click to view]

I have found that if you check the bytes_total too soon, it returns the
value of the empty clip instead of the size of the external file. What I do
(and there may be a better way) is to make sure that the value of
bytes_total is not too small, otherwise I consider it invalid.. like this:

bytes_total = Math.round(_root.loader.getBytesTotal());
if(bytes_total < 1000) // (assuming your external clip is bigger than
1,000)
return; // not valid yet so exit

You can find out if that is the problem by putting a trace at "DONE"
trace(bytes_total);
My bet is that it will say some small number like 12 to 100 depending on
what's in the empty clip.

hope that helps
tralfaz

tralfaz
3/28/2004 2:07:40 PM
[quoted text, click to view]

Hi.. I recently had been using that zero check method until I ran into a
problem with it. I had an empty movieclip that was just a blank unfilled
frame that showed where the pictures would load. The total_bytes check was
returning 12 bytes and jumping to the "done" frame. I had to change it from
a non-zero check to a higher number than 12 before it would work. Since I
was loading 100k images I just checked that total_bytes was greater than 1k.
tralfaz

vinnyvarda
3/28/2004 8:46:02 PM
Hello,

I was wondering if anyone could help with a problem I'm having loading an
external .swf into an empty clip. I'm using the following code, and it works
fine in the first frame of a movie loaded externally but not in the preloader
in the main movie;

bytes_loaded = Math.round(_root.loader.getBytesLoaded());
bytes_total = Math.round(_root.loader.getBytesTotal());
getPercent = bytes_loaded/bytes_total*100;
percent_done = int((bytes_loaded/bytes_total)*100);
this.bar.gotoAndStop(percent_done);
this.loadText = Math.round(getPercent)+"%";
if (bytes_loaded == bytes_total) {
this.gotoAndStop("done");
}

"loader" is the MC that I use throughout to load and unload .swf but
regardless of the size of the .swf I'm loading using the above code jumps
straight to "done" any help would be apprecitated.

ltd
N Rohler
3/28/2004 9:56:33 PM
it looks like the issue is that you check to see if it's loaded before it has
actually started (it doesn't start immediately). Try changing
if (bytes_loaded == bytes_total) {
to
if (bytes_loaded == bytes_total && bytes_total != 0) {

i think that might fix your issue


AddThis Social Bookmark Button