PDA

View Full Version : K/s on preloader?



grandsp5
September 14th, 2003, 02:46 AM
How would you do it? I imagine the code would be something like

var bytesLastLoaded = 0;
fps = 20;
onEnterFrame{
loaded = _root.getBytesLoaded();
speed = (loaded - bytesLastLoaded)*fps;
bytesLastLoaded = loaded;
}


Would something like this work or is there a better way to do it? Ideally I wouldn't use fps, I would use setInterval but this was what I just pulled out of my head a second ago. I guess I could also use getTimer somehow

blah-de-blah
September 14th, 2003, 03:29 AM
I dotn' get it :-\ what do you want to do?? seems weird to me that bytesLastLoaded = loaded, which equals getBytesLoaded().

Why don't you just do bytesLastLoaded = _root.getBytesLoaded();??

And why multiply with fps?? And didn't you just say in the random section about people having too many preloader questions ? :P

kode
September 14th, 2003, 03:52 AM
var t = getTimer();
this.onEnterFrame = function() {
var kbl = this.getBytesLoaded()/1024;
var kbps = Math.floor(kbl/((getTimer()-t)/1000)*100)/100;
};
You'll get a number rounded off to two decimal places.

grandsp5
September 14th, 2003, 05:07 AM
blah: :) i searched and found nothing on this before. my code was on the basis of the enterFramevent happening at the framerate of the movie, thus multiplying by the framerate to get k/s.

Kode: Thank you. You come to the rescue yet again. I forgot to divide by 1024...my bad

kode
September 14th, 2003, 05:42 AM
:P

Anytime, grandsp5. ;)