# loadVars puzzle

**URL:** https://forum.kirupa.com/t/loadvars-puzzle/6851
**Category:** flash
**Created:** [October 17, 2002, 7:09pm UTC](https://forum.kirupa.com/t/loadvars-puzzle/6851 "2002-10-17T19:09:59Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Iammontoya](https://avatars.discourse-cdn.com/v4/letter/i/bbce88/32.png) [@Iammontoya](https://forum.kirupa.com/u/Iammontoya)
#### Post date: [October 17, 2002, 7:09pm UTC](https://forum.kirupa.com/t/loadvars-puzzle/6851/1 "2002-10-17T19:09:59Z")

</div>

To my geeky friends…

I’ve come across this puzzle, I hope you guys can help me figure it out.

It really is quite simple. I have a text file called sites.txt. I want to load the variables from that file and use them in my movie. I have a dynamic text box on my \_root. I called it Mybox.

Here’s the puzzle.

This doesn’t work

```auto

newload=new loadVars();
newload.load("sites.txt");
newload.onLoad=function(){
	trace(newload.toString());
	
}
_root.mybox.text=newload.hello;

```

But, this one works.

```auto

newload=new loadVars();
newload.load("sites.txt");
newload.onLoad=function(){
	trace(newload.toString());
	_root.mybox.text=newload.hello;
}

```

Notice that the only change is the location of the “\_root.mybox.text=newload.hello;” piece of code. However, this variable is supposed to be available anywhere else in the movie.

Once we talk about this one, I’ll give you a second, similar puzzle with loadvariables();

---

<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: [October 17, 2002, 7:54pm UTC](https://forum.kirupa.com/t/loadvars-puzzle/6851/2 "2002-10-17T19:54:45Z")

</div>

Geek reporting, Sir.

Elementary, my dear Watson. In the first piece of code, you’re trying to access newload.hello but it’s empty. The loading isn’t done yet. And even if it was done (that is to say instantaneous), the data is available on the next frame.

In the second piece of code, you access the data when it is actually loaded (onLoad…).

Waiting for the other one… :cowboy:

---

<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: [October 17, 2002, 8:24pm UTC](https://forum.kirupa.com/t/loadvars-puzzle/6851/3 "2002-10-17T20:24:12Z")

</div>

Interesting, interesting… see, in my mind, all was loadead. I realize that it is running all the code before the load ends. Okee…

I will load the second later… 🙂

---

<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: [October 17, 2002, 8:26pm UTC](https://forum.kirupa.com/t/loadvars-puzzle/6851/4 "2002-10-17T20:26:34Z")

</div>

hehe 🙂
