Using LoadVars.getBytesLoaded and LoadVars.getBytesTotal

hey peeps,
Whenever i try to display anything returned by LoadVars.getBytesLoaded or Load…Total, it gives me NaN. Does anyone know how to overcome this problem? Thanks in advance

Do you do this?


yourLoadedVars = new LoadVars();
yourLoadedVars.load("text.txt")
trace(yourLoadedVars.getBytesLoaded)

or are you just useing


LoadVars.load("text.txt")
trace(LoadVars.getBytesLoaded)

:}

Master64, i dont think you can use that with LoadVars :-\

hamza84: do you need to display loading pregress or just a loading message?

claudio, getBytesLoaded/Total is indeed a method of the LoadVars class :slight_smile:

oh my bad :slight_smile:
check this

Master 64 - Wouldn’t that be

[AS]
yourLoadedVars = new LoadVars();
yourLoadedVars.load(“text.txt”)
trace(yourLoadedVars.getBytesLoaded())
[/AS]

Ok i guess my last post was i bit confusing :-\

you can use yourLoadedVars.getBytesLoaded

but the way hamza84 sad it. it look like he/she was trying to use getBytesLoaded right of the class and not useing new …

Voetsjoeba sorry whated to answer quickly before you guys got there before me…[size=1] which happens alot :P[/size]

Lol, 't is precies of we zijn hier aan’t racen voor nen thread op te losse :stuck_out_tongue:

hamza84 - Don’t forget the ()'s at the end of getBytesLoaded and getBytesTotal. The correct syntax is getBytesLoaded() and getBytesTotal().

try something like this:

lv = new LoadVars();
lv.load("somefile.txt");
onEnterFrame = function() {
if(lv.getBytesLoaded()<lv.getBytesTotal()) trace ( 100*lv.getBytesLoaded()/lv.getBytesTotal() )
else delete this.onEnterFrame
}

^ What ? You don’t need the ()'s ? D’oh :stuck_out_tongue: Oh well, another entry to my brain’s records won’t hurt.

edited my post :wink:

ARGH ! Don’t confuse me :stuck_out_tongue:

G ahmed nice and all but… keep it simple for the newbies :stuck_out_tongue:

Hey! wheres my say in this whole discussion!? Anyways, here;s the code that I used. In the first frame, I used this code:

[AS]loadtext = new LoadVars();
loadtext.load(“about.txt”);[/AS]

In the second frame i used this code:

[AS]total = loadtext.getBytesTotal();
loadedbytes = loadtext.getBytesLoaded();
loading = Math.floor(loadedbytes/total);[/AS]

and finally, in the third frame, i used the following code:

[AS]if(loadedbytes < total)
gotoAndPlay(2);

else
{
box.html = true;
box.htmlText = this.aboutText;
this.stop;
}[/AS]

I’m trying to display a message while the darn thing is loading. And btw, I’m a male. =)

errrr

try


//1//
loadtext = new LoadVars();
loadtext.onLoad = function(){
        box.html = true;
        box.htmlText = this.aboutText;
       gotoAndStop(4);
}
loadtext.load("about.txt");
//2//
total = loadtext.getBytesTotal();
loadedbytes = loadtext.getBytesLoaded();
loading = Math.floor(loadedbytes/total);
//3//
gotoAndStop(2);

but its looks fine to me:-\

and your edit too :wink:

exept


if(loadedbytes < total){
gotoAndPlay(2);
}else{
        box.html = true;
        box.htmlText = this.aboutText;
        this.stop**()**;
}

I tried all of the codes. Still doesnt work. Wierd

try removeing you text fields and just trace the variable…
if you have var in the “var” thing in text field and the text field is rested(if it come in a frame where the text field is make(which happen when you use gotoAndPlay()) the var gets reset… that might be the prob;)

Going to bed (school tomorrow :frowning: )