Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preloaders- percent loaded, measured by KB 2

Status
Not open for further replies.

carpeliam

Programmer
Mar 17, 2000
990
US
So far, in preloaders that show what percentage has been loaded so far, I've seen it as (framesLoaded / totalFrames). Is there anyway to measure how much has been loaded depending on kilobytes, not frames? I only need to preload the first frame, as all the graphics in the movie are in that frame. Measuring by framesLoaded, it would go from 0% to 100% instantaneously (as totalFrames is set to 1). Can I measure by kilobytesLoaded? How might I be able to do that, if possible? Thanks... :eek:) <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href= imotic ::</a><br>
 
apparently now in Flash MX you can.

MovieClip.getBytesLoaded
Availability: Flash Player 6.
Usage: myMovieClip.getBytesLoaded()

MovieClip.getBytesTotal
Availability: Flash Player 5.
Usage: myMovieClip.getBytesTotal() Liam Morley
lmorley@gdc.wpi.edu
&quot;light the deep, and bring silence to the world.
light the world, and bring depth to the silence.&quot;
 
getBytesLoaded() and getBytesTotal() were both available in version 5 ...
 
getBytesTotal()/getBytesLoaded() cannot be trusted when the value is belowe 100 or so.
When starting to load the getBytesTotal() is not correct.
So when building a preloader you should do like this:
if(getBytesLoaded()<100) {
//do nothing, just gotoAndplay preload
}else{
if(getbytesLoaded()<getBytesTotal()){
// display how much is loaded
// gotoAndplay preload
} else {
// totoAndplay preload is done
}
}
 
I'd like to know where you got this info from ... I don't think it's correct. I think the reason you're having problems below 100Kb is that you have way too much in your preloader.

Simple preloaders shouldn't contain anything more than some static text to indicate loading is taking place, plus a preload bar graphic and (optionally) some dynamic textfields with the KB loaded, or percentage of movie loaded - and in both cases there should be NO FONT OUTLINES INCLUDED in the textfields. Adding font outlines for Arial lumps 25Kb on to your movie's size, and if the font is required for the preloader, the preloader won't work until the font has downloaded.

If you want a more graphic preloader, you should stagger the preloader, so that it builds up gradually, rather than having a blank screen for 20 seconds whilst your first 100K downloads.
 
That is so true, that at one point, you could need a preloader to load your preloader! And all of that to only see that preloader once in a while! Regards,

new.gif
 
This is from the advances flash 5 programming CD, it says the getBytestotal() is sometimes not correct.
Anyway when getBytesloaded() is bigger than 100 (should take more than a fraction of a second) your script will run as usual but before that you should't trust the getBytestotal().
 
&quot;Anyway when getBytesloaded() is bigger than 100 (should take more than a fraction of a second) your script will run as usual but before that you should't trust the getBytestotal().&quot;

Are you talking about 100 BYTES or 100 KILOBYTES? If you're talking about kilobytes, 100Kb will take approx. 25 seconds to download on a standard home 56K modem connection.
 
First, you're right rgstewart. The original question was posed in March of 2000, several months before Flash 5 was released (circa sept. 2000). As I really didn't worry about preloaders in between March of 2000 and now, I never looked into it all the time I was using Flash 5. As I thought there was a direct correspondence between Flash Player 6 and the Flash MX development environment, I thought that this was a Flash MX feature; thank you for correcting me.

Second, harmmeijer never mentioned kb.. I think the only place that kb were mentioned was in the original question. So I assume he meant bytes. Liam Morley
lmorley@gdc.wpi.edu
&quot;light the deep, and bring silence to the world.
light the world, and bring depth to the silence.&quot;
 
Why would you bother trying to preload just over a tenth of a kilobyte?!
 
if you read his code:
Code:
if (getBytesLoaded() < 100)
not:
Code:
if (getBytesTotal() < 100)
Liam Morley
lmorley@gdc.wpi.edu
&quot;light the deep, and bring silence to the world.
light the world, and bring depth to the silence.&quot;
 
So you're saying ... ? It just seems like a totally futile exercise to even think about whether values of under 100 bytes are accurate or not, that's all ...
 
Does there have to be a point, old? Anyways, if you read my last post you would SEE the point I am making. It may not be a particularly productive one, granted, but nobody is forcing anyone to read this.
 
Well you posted at the same time I did, and didn't see it!
But futile is exactly what I ment by Can someone tell me the point in all of this? Regards,

new.gif
 
Ah, but can't much of human existence be summed up bu the word &quot;futillity&quot; ... ?

:)

Settle, petal ...
 
Ah, but can't much of human existence be summed up by the word &quot;futillity&quot; ... ?

:)

Settle, petal ...
 
I think if you can read the code, you'd be set.

As was mentioned, the first 100 bytes are loaded in a fraction of a second. Within that fraction of a second, a reliable value for getBytesTotal() does not exist. So what the above code does is ignore getBytesTotal() altogether until getBytesLoaded() is greater than 100.

This has nothing to do with getBytesTotal() actually being equal to 100, as you can see in the code- so what I was saying (and what I was hoping would be plain as day by just reading the code) was that you're not preloading just 1/10th of a kilobyte. Rather, in the time it takes to load 1/10th of a kilobyte, you really have no idea how much you're trying to load in total.

Now I have two problems with the code. First, would the getBytesTotal() ever be so unreliable that it would be less than or equal to getBytesLoaded()? If not, then the problem can be ignored altogether. Otherwise, then the code is somewhat necessary to keep you from loading a movie far before it's ready. Second, the code can't be used if getBytesTotal() actually is less than 100 bytes.. but that's pretty unlikely and, as was previously mentioned, there's no need for a preloader in that case.

Hopefully the code makes more sense to you now and is less &quot;futile&quot;. Liam Morley
lmorley@gdc.wpi.edu
&quot;light the deep, and bring silence to the world.
light the world, and bring depth to the silence.&quot;
 
This is more like fly sodomy, if you ask me!
Sheeeessssssssssssssssssssssh! Regards,

new.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top