# Wait until external data loads

**URL:** https://forum.kirupa.com/t/wait-until-external-data-loads/63831
**Category:** Uncategorized
**Created:** [September 10, 2004, 10:58am UTC](https://forum.kirupa.com/t/wait-until-external-data-loads/63831 "2004-09-10T10:58:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![fightalone](https://avatars.discourse-cdn.com/v4/letter/f/22d042/32.png) [@fightalone](https://forum.kirupa.com/u/fightalone)
#### Post date: [September 10, 2004, 10:58am UTC](https://forum.kirupa.com/t/wait-until-external-data-loads/63831/1 "2004-09-10T10:58:44Z")

</div>

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

---

<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: [September 10, 2004, 1:00pm UTC](https://forum.kirupa.com/t/wait-until-external-data-loads/63831/2 "2004-09-10T13:00:04Z")

</div>

Do you mean something like this?:

```auto

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

---

<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: [September 10, 2004, 4:21pm UTC](https://forum.kirupa.com/t/wait-until-external-data-loads/63831/3 "2004-09-10T16:21:59Z")

</div>

thx…

---

<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: [September 10, 2004, 4:38pm UTC](https://forum.kirupa.com/t/wait-until-external-data-loads/63831/4 "2004-09-10T16:38:00Z")

</div>

Any time
