View Full Version : Using LoadVars.getBytesLoaded and LoadVars.getBytesTotal
hamza84
September 1st, 2003, 02:44 PM
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
Johnny64
September 1st, 2003, 02:55 PM
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)
:}
claudio
September 1st, 2003, 02:59 PM
Master64, i dont think you can use that with LoadVars :-\
hamza84: do you need to display loading pregress or just a loading message?
ahmed
September 1st, 2003, 03:02 PM
claudio, getBytesLoaded/Total is indeed a method of the LoadVars class :)
claudio
September 1st, 2003, 03:06 PM
oh my bad :)
check this
Voetsjoeba
September 1st, 2003, 03:07 PM
Master 64 - Wouldn't that be
yourLoadedVars = new LoadVars();
yourLoadedVars.load("text.txt")
trace(yourLoadedVars.getBytesLoaded())
Johnny64
September 1st, 2003, 03:11 PM
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..... which happens alot :P
Voetsjoeba
September 1st, 2003, 03:13 PM
Lol, 't is precies of we zijn hier aan't racen voor nen thread op te losse :P
hamza84 - Don't forget the ()'s at the end of getBytesLoaded and getBytesTotal. The correct syntax is getBytesLoaded() and getBytesTotal().
ahmed
September 1st, 2003, 03:15 PM
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
}
Voetsjoeba
September 1st, 2003, 03:16 PM
^ What ? You don't need the ()'s ? D'oh :P Oh well, another entry to my brain's records won't hurt.
ahmed
September 1st, 2003, 03:17 PM
edited my post ;)
Voetsjoeba
September 1st, 2003, 03:17 PM
ARGH ! Don't confuse me :P
Johnny64
September 1st, 2003, 03:18 PM
G ahmed nice and all but.... keep it simple for the newbies :P
hamza84
September 1st, 2003, 03:48 PM
Hey! wheres my say in this whole discussion!? Anyways, here;s the code that I used. In the first frame, I used this code:
loadtext = new LoadVars();
loadtext.load("about.txt");
In the second frame i used this code:
total = loadtext.getBytesTotal();
loadedbytes = loadtext.getBytesLoaded();
loading = Math.floor(loadedbytes/total);
and finally, in the third frame, i used the following code:
if(loadedbytes < total)
gotoAndPlay(2);
else
{
box.html = true;
box.htmlText = this.aboutText;
this.stop;
}
I'm trying to display a message while the darn thing is loading. And btw, I'm a male. =)
Johnny64
September 1st, 2003, 04:02 PM
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:-\
Johnny64
September 1st, 2003, 04:05 PM
and your edit too ;)
exept
if(loadedbytes < total){
gotoAndPlay(2);
}else{
box.html = true;
box.htmlText = this.aboutText;
this.stop();
}
hamza84
September 1st, 2003, 04:14 PM
I tried all of the codes. Still doesnt work. Wierd
Johnny64
September 1st, 2003, 04:27 PM
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 :( )
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.