# getBytesTotal for loadVariables?

**URL:** <https://forum.kirupa.com/t/getbytestotal-for-loadvariables/96625>\
**Category:** Uncategorized\
**Created:** [December 11, 2003, 6:15pm UTC](https://forum.kirupa.com/t/getbytestotal-for-loadvariables/96625 "2003-12-11T18:15:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![larcho](https://avatars.discourse-cdn.com/v4/letter/l/ce7236/32.png) [@larcho](https://forum.kirupa.com/u/larcho)\
**Post date:** [December 11, 2003, 6:15pm UTC](https://forum.kirupa.com/t/getbytestotal-for-loadvariables/96625/1 "2003-12-11T18:15:48Z")

</div>

Hi there, my first post.

I’m doing my portfolio in FlashMX using Actionscript. Everything in that sites has a preloader.

Anyway, in the actual portfolio section I use variables form a .txt to load each work (that way I can add in a more easy way new content). The .txt contains location of images, text shown, titel, and some other variables. Each .txt is aprox. 350bytes.

The problem is that if the variables aren’t loaded fast enough the content of each work is shown wrong.

Is there a way to calculate getBytesTotal() for variables ?

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 12, 2003, 12:59am UTC](https://forum.kirupa.com/t/getbytestotal-for-loadvariables/96625/2 "2003-12-12T00:59:05Z")

</div>

Thank you very much, I apreciate your help.

I’m really new to actionscripting so I’m not getting completle what you wrote there.

But I’ll come around.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 12, 2003, 1:03am UTC](https://forum.kirupa.com/t/getbytestotal-for-loadvariables/96625/3 "2003-12-12T01:03:21Z")

</div>

Mmm … it’s quite clear for me now … this thought I don’t understand completly

if (loaded\>0 && loaded == total) {

I know this checks if the data is loaded but why the \>0 &&

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 12, 2003, 2:32am UTC](https://forum.kirupa.com/t/getbytestotal-for-loadvariables/96625/4 "2003-12-12T02:32:55Z")

</div>

var data\_lv = new LoadVars();  
data\_lv.load(“data.txt”);  
bar\_mc.onEnterFrame = function() {  
var loaded = data\_lv.getBytesLoaded();  
var total = data\_lv.getBytesTotal();  
this.\_xscale = 100\*loaded/total;  
if (loaded\>0 && loaded == total) {  
trace(“The file has been loaded!”);  
delete this.onEnterFrame;  
}  
};

loaded is the total bytes that have already been loaded from the object data\_lv.

if (loaded\>0 && loaded == total) {  
^^translated: if the variable loaded is greater than zero AND if loaded is equal to total (the total amout of bytes that need to be loaded) then continue with this:

trace(“The file has been loaded!”);  
delete this.onEnterFrame;

and it checks for \>0 b/c the total bytes can be zero and the total bytes loaded can be zero, and it will continue, thus loaded \> 0

and if you wanted to get REALLY fancy you could do this :

if (loaded\>0 && loaded === total) {

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 13, 2003, 6:50am UTC](https://forum.kirupa.com/t/getbytestotal-for-loadvariables/96625/5 "2003-12-13T06:50:36Z")

</div>

Kode, just letting you know that the script worked fine.

Thanks for the help, big time.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 14, 2003, 8:36pm UTC](https://forum.kirupa.com/t/getbytestotal-for-loadvariables/96625/6 "2003-12-14T20:36:38Z")

</div>

You’re welcome, larcho. 😉
