getBytesTotal for loadVariables?

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 ?


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.

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 &&

var data_lv = new LoadVars();
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) {

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

Thanks for the help, big time.

You’re welcome, larcho. :wink: