PDA

View Full Version : totalBytes works only on local machine



k/smaert
March 10th, 2004, 11:59 PM
I have made a preloader showing the progress of dynamically added images. The code works fine when i play the movie on local machine, but when i play the movie from the server bytesTotal is always 0. It even says 0 after the images has finished loading.

what i'm doing is basically: createEmptyMovieClip() , i then use a movieClipLoader to load jpeg into that empty movieclip. the movieClipLoader has a listener attached and with the listener i use the function onLoadProgress() to display bytesLoaded and bytesTotal

all of these things occur within one function..

bytesLoaded works fine both on local machine and from the server

BlueBoots
March 11th, 2004, 12:35 AM
Originally posted by k/smaert
I have made a preloader showing the progress of dynamically added images.
<-- I used external .swfs, but it's the same thing really./>

The code works fine when i play the movie on local machine, but when i play the movie from the server bytesTotal is always 0. It even says 0 after the images has finished loading.
<-- Bummer./>

what i'm doing is basically: createEmptyMovieClip() , i then use a movieClipLoader to load jpeg into that empty movieclip. the movieClipLoader has a listener attached and with the listener i use the function onLoadProgress() to display bytesLoaded and bytesTotal

<-- I avoided this stuff. I'm in MX, and I used a cycling loader.
Frame one on the main timeline, instead of creating an empty clip I attached a blank movie clip from my library off to one side of the stage:

attachMovie("blank","hold1",1);
attachMovie("blank","hold2",2);

hold1.loadMovie("YourImage1.swf");
hold1._x = -800;

hold2.loadMovie("YourImage2.swf");
hold2._x = -800;

and I gave them new easy instance names.

Instead of your listener, I used addition.

On Frame Three of the main timeline I have :


loadedBytes = this.getBytesLoaded() + hold1.getBytesLoaded() + hold2.getBytesLoaded();

totalBytes = this.getBytesTotal() + hold1.getBytesTotal() + hold2.getBytesTotal();


if (loadedBytes == totalBytes) {
_root.gotoAndPlay(5);
}
percentage = Math.round(loadedBytes/(totalBytes/100));
loader.gotoAndStop(percentage);
loader.counter.percent.text = percentage;


This means I can change the content of the externally loaded files nice'n'easy.
The last thing of course, is to tell it on Frame Four of the Main Timeline:

gotoAndPlay(2);

So it cycles. Looks harder than it is. I pushed the loader on Frame Three a frame away from the attach script on Frame One, because some stupidly old machines repeatedly attached the movies!

/-->

all of these things occur within one function..
<-- That might be your problem...
/-->
bytesLoaded works fine both on local machine and from the server

Let me know if it doesn't work, k?

<blue/>

k/smaert
March 11th, 2004, 12:50 AM
<-- I avoided this stuff. I'm in MX, and I used a cycling loader./-->

all of these things occur within one function..
<-- That might be your problem...
/-->

yeah i might have to break it all apart and create the cycly loader you are talking about..i just thought since there are functions for doing all this in one frame i might as well us it...the onLoadProgress is working as the cyclic loader..it just won't display the correct totalBytes when loading from server


loadListen[i].onLoadProgress = function(clip, bytesLoaded, bytesTotal){ //display download status of picture
var nr = parseInt(clip._name.substr(clip._name.lastIndexOf("p")+1));
var stats:Object = imgLoad[nr].getProgress(clip);
_root["imgL"+nr].text= "Bytes loaded: " + stats.bytesLoaded +" of "+ stats.bytesTotal;
_root["imgL"+nr].setTextFormat(text_format);
}