Wait until external data loads

ok… this my prob:

i’ve got a function which loads data from an external .txt (an interger value)… this basically works fine… BUT… the problem is that the script doesnt wait for

 _global.iPicNumber = 0;
 loadText = new LoadVars();
 loadText.load(_global.sPicPath + 'PicNr.txt');
** loadText.onLoad = function()**
 {
         _global.iPicNumber = this.iNumber;
         trace("COUNT 01" + _global.iPicNumber);
 };
         trace("COUNT 02" + _global.iPicNumber);

to sucess… the whole script is done before _global.iPicNumber is set;

the output: COUNT 02 = 0;
COUNT 01= 18; //this is what it should be

the script simply doesnt wait until loadText.onLoad = function() is execurted… and this is a problem…

i need to tell the script to wait until _global.iPicNumber is set…

any ideas how to solve this problem…??

thx in advance

yours sincerly

Do you mean something like this?:


loadText = new LoadVars();
loadText.load(_global.sPicPath + 'PicNr.txt');
loadText.onLoad = function(success)
{
if (success) {
trace("COUNT 01" + this.iNumber);
executeRest(this.iNumber);
}
};
executeRest = function(aNumber){
trace("COUNT 02" + aNumber);
}



this way you just include the rest of your actions in a (or several) function
tha’s only called if vars are loaded.

SHO

thx…

Any time