# loadVariables

**URL:** <https://forum.kirupa.com/t/loadvariables/2890>\
**Category:** Uncategorized\
**Created:** [February 26, 2002, 7:51pm UTC](https://forum.kirupa.com/t/loadvariables/2890 "2002-02-26T19:51:53Z")\
**Posts on this page:** 15\
**Page:** 1

<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:** [February 26, 2002, 7:51pm UTC](https://forum.kirupa.com/t/loadvariables/2890/1 "2002-02-26T19:51:53Z")

</div>

Hi there!\r\rI want to load Variables from a .txt-file to edit the properties of a movieClip. For example: 700 is written in the .txt-file. After loading the Clip the x-position of the clip should be set to 700. How can I do this?\r\rTHX

---

<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:** [February 26, 2002, 10:03pm UTC](https://forum.kirupa.com/t/loadvariables/2890/2 "2002-02-26T22:03:59Z")

</div>

write a txt file called “variables.txt” :\r\rx=700\r\ron the movieclip in question:

```auto
 \r\ronClipEvent(load){\r\r loadVariables("variables.txt",this);\r\r}\r\r\r\ronClipEvent(data){\r\r _x = x;\r\r}

```

\r\rvariables.txt will have to be in the same directory as the swf. if you want to put it somewhere else, that’s fine, but you’ll have to reflect those changes in the load variables statement.\r

---

<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:** [February 26, 2002, 10:31pm UTC](https://forum.kirupa.com/t/loadvariables/2890/3 "2002-02-26T22:31:11Z")

</div>

Can you explain how that onClipEvent (data) works ?\rpom 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:** [February 27, 2002, 2:48am UTC](https://forum.kirupa.com/t/loadvariables/2890/4 "2002-02-27T02:48:46Z")

</div>

it’s an event handler that fires when a movie has finished loading from a loadVariables call OR fires continuously during a loadMovie (useful for load meters).

---

<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:** [February 27, 2002, 8:27am UTC](https://forum.kirupa.com/t/loadvariables/2890/5 "2002-02-27T08:27:38Z")

</div>

Hi once again!\r\rI’ve tried to load variables with “onClipEvent (data)” but it didn’t work. The .swf doesn’t read the variables, because I made a testtextfiled that should write the value of the read variable but it was blank after loading the clip.\rAny idea?\r\rTHX

---

<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:** [February 27, 2002, 8:50am UTC](https://forum.kirupa.com/t/loadvariables/2890/6 "2002-02-27T08:50:28Z")

</div>

I tried it, and it works nice and smooth. What I did is the following :\rI put a DYNAMIC text box that I called “test”, no “”.\rI drew a small circle outside the scene, turned it into a movie clip, then copied and pasted Supra’s code in its Actions panel, changing it a little bit into

```auto
 onClipEvent (load) {\r\r loadVariables ("variables.txt", this);\r\r}\r\ronClipEvent (data) {\r\r _root.test = x;\r\r}

```

One important thing is that you have to put the text in the same folder as the swf\r\rpom 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:** [February 27, 2002, 3:40pm UTC](https://forum.kirupa.com/t/loadvariables/2890/7 "2002-02-27T15:40:56Z")

</div>

Hi!\r\rTrying the thing with the textfield works fine, but applying the x-value to \_x still doesn’t. When writing \_x = 700 everything is alright, but writing \_x = x has no effect. Why?

---

<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:** [February 27, 2002, 8:51pm UTC](https://forum.kirupa.com/t/loadvariables/2890/8 "2002-02-27T20:51:56Z")

</div>

It works.

```auto
 onClipEvent (load) {\r\r&nbsp &nbsp &nbsp &nbsp loadVariables ("variables.txt", this);\r\r}\r\ronClipEvent (data) {\r\r&nbsp &nbsp &nbsp &nbsp _root.test = x;\r\r&nbsp &nbsp &nbsp &nbsp _x = x/3 ;\r\r}

```

Remember that all this is the code for a movie clip. If it dosn’t work, just gimme your email adress, I’ll send you the fla.\r\rpom 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:** [February 28, 2002, 7:42am UTC](https://forum.kirupa.com/t/loadvariables/2890/9 "2002-02-28T07:42:10Z")

</div>

Hi!\r\rI’m goin’ crazy!!! Please send me your .fla so that I can compare: [hartwig@ortbauer.cc](mailto:hartwig@ortbauer.cc)\r\rTHX a lot\r\rHartwig

---

<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:** [February 28, 2002, 7:46am UTC](https://forum.kirupa.com/t/loadvariables/2890/10 "2002-02-28T07:46:14Z")

</div>

sent.\rpom 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:** [February 28, 2002, 8:47am UTC](https://forum.kirupa.com/t/loadvariables/2890/11 "2002-02-28T08:47:05Z")

</div>

THX for your fla! It works, as U said. BUT I HAVE NO IDEA WHY MY FLA WHICH LOOKS QUIET THE SAME DOESN’T WORK! Thanks anyway!

---

<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:** [February 28, 2002, 10:31am UTC](https://forum.kirupa.com/t/loadvariables/2890/12 "2002-02-28T10:31:50Z")

</div>

[ilyas.usal@club-internet.fr](mailto:ilyas.usal@club-internet.fr)\rI’ll take a look at it.\rpom 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:** [March 17, 2002, 2:04am UTC](https://forum.kirupa.com/t/loadvariables/2890/13 "2002-03-17T02:04:53Z")

</div>

Here is what I have so far, and I think I’m running into similar issues, although slightly different than the topic.\r\rI have a text file called quotes.txt\r\rIn it I have several quotes like so:\r\rquote1=whateveritis&quote2=thisiswhatitis&quote3=nevermindwhatitis\r\rI have one text box in flash and the following script:\r\rvar test = random (3) + 1;\rvar ques = ‘quote’ + test;\rloadVariablesNum (“quotes.txt”, 0);\r\_root.quotedisplayvar = ques;\r\r\rNow what I’m trying to get it to do is pick 1 of the 3 quotes from the text file. There are three there, need it to randomly pick 1 and display it in the text box in flash. The problem is, based on the above script, what it is doing is displaying \r\rquote1 - quote 2 - quote 3 instead of the actual quote from the file.\r\rAny thoughts?\r\rChris

---

<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:** [March 17, 2002, 11:02am UTC](https://forum.kirupa.com/t/loadvariables/2890/14 "2002-03-17T11:02:49Z")

</div>

Yes, you have to evaluate the result. The easiest way would be to put \_root.whereeveryouare[“quote”+test] ;\rNotice that there is no “.” before the []. I’ll try to make it work. Just be careful with the path you’re using. I know Suprabeener would kill me for that, but putting it in \_root would be easier.\r\rpom 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:** [March 17, 2002, 1:36pm UTC](https://forum.kirupa.com/t/loadvariables/2890/15 "2002-03-17T13:36:21Z")

</div>

As ilyas said, you are putting the resulting name of quote in there, not it’s content, which you’ll extract using eval.
