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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML getBytesTotal()

Status
Not open for further replies.

gameon

Programmer
Feb 23, 2001
325
GB

Hi, I have set up a news scroll for my site. The content is loaded in as xml.

I have put a liitle load window on the front. It works great, using:

this.TheNews.getBytesLoaded();

But, I don't think people are interested in the bytes - so I just want to display the percentage.

This also works, but badly as far as I'm concerned.

Basically, the bytes loaded slowly goes up and up - but the this.TheNews_init.getBytesTotal(); does not appear until the file has completly loaded. Meaning my bytes goes up, then it appears as 100 at the end.

I have thought of loading the xml in twise. Once, to find the files size - and then to compare it with bytes loaded on the second run. But this can't be the best way.

here is an extract from my debug:

0 of
0 of
0 of
9684 of 0
12392 of 0
12392 of 12392
12392 of 12392

Please advise...

M@)
 
It might be a timing thing - if you only request the total file size once at the start of the load you may not be giving the script time to interrogate the file and return the correct number of bytes.

If you had the following in a frameloop or within an onEnterFrame event you should be able to return a percentage which will be of more use to your visitors:

soFar=this.TheNews.getBytesLoaded();
total=this.TheNews.getBytesTotal();
percent=Math.round(soFar/total*100)

... this way the total is being requested each loop which will clear any latency or odd values at the start of the load.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top