# Passing variables between movies

**URL:** <https://forum.kirupa.com/t/passing-variables-between-movies/2775>\
**Category:** flash\
**Created:** [April 14, 2002, 5:35pm UTC](https://forum.kirupa.com/t/passing-variables-between-movies/2775 "2002-04-14T17:35:01Z")\
**Posts on this page:** 8\
**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:** [April 14, 2002, 5:35pm UTC](https://forum.kirupa.com/t/passing-variables-between-movies/2775/1 "2002-04-14T17:35:01Z")

</div>

I have two movies: m1 and m2. In m1 I set a variable to variable=“yes”. Now, I want m2 to read the variable and do an action depended on the variable (see the example below).\rHow do I do this?\r\rThis is the AS in m1:\r\ron (release) {\r&nbsp &nbsp &nbsp &nbsp docufield = “background.txt”;\r}\r\rAnd this is the AS in m2:\r\rthis.loadVariables(docufield);\r\rAchnor

---

<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:** [April 14, 2002, 5:49pm UTC](https://forum.kirupa.com/t/passing-variables-between-movies/2775/2 "2002-04-14T17:49:30Z")

</div>

2 movie clips or 2 swf ?? Cos you can’t load variables from a swf (nor from a movie clip by the way…).\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:** [April 14, 2002, 5:50pm UTC](https://forum.kirupa.com/t/passing-variables-between-movies/2775/3 "2002-04-14T17:50:28Z")

</div>

two swf…it can’t be done?\r\rHere’s the full story:\rI have a menu.swf and a document.swf, both loaded into a holder.swf. When I click on the menu I want to pass a variable telling document.swf wich .txt to read from and display on-screen.\r\rAchnor

---

<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:** [April 14, 2002, 7:07pm UTC](https://forum.kirupa.com/t/passing-variables-between-movies/2775/4 "2002-04-14T19:07:22Z")

</div>

you just have to target the variable properly.\rwhether you loaded into a target or a level you have to path to that clip.\rexample:\rif you loaded the 2 swf’s into levels 1 and 2 respectively the paths would be something like this…\r\_level1.myVariable\r\_level2.myVariable\rif you loaded into targets named mc1 and mc2 the paths would look like this…\r\_level0.mc1.myVariable\r\_level0.mc1.myVariable\ror…\r\_root.mc1.myVariable\r\_root.mc2.myVariable\r\rwhen swf’s are loaded into other swf’s they are basically movie clips and can be targeted as such.\r:) \rjeremy

---

<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:** [April 14, 2002, 8:33pm UTC](https://forum.kirupa.com/t/passing-variables-between-movies/2775/5 "2002-04-14T20:33:21Z")

</div>

Thanks. I guess this will work, however, I’ve encountered another problem. As described above, I set a varibale (docufield) to “data.txt”, but, when I do this:\r\ronClipEvent (load){\r&nbsp &nbsp &nbsp &nbsp this.loadVariables(docufield);\r}\r\rit wont load data.txt. Can’t I use variables this way?\r\rAchnor

---

<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:** [April 14, 2002, 10:28pm UTC](https://forum.kirupa.com/t/passing-variables-between-movies/2775/6 "2002-04-14T22:28:52Z")

</div>

it should work. i did a test and it was fine.\rtest your movie and then go to ‘debug’ and ‘list variables’. you should see the variables that were loaded in the output window.\r:) \rjeremy

---

<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:** [April 15, 2002, 6:49pm UTC](https://forum.kirupa.com/t/passing-variables-between-movies/2775/7 "2002-04-15T18:49:44Z")

</div>

Yup. It worked. The reason it didn’t work in the beginning was because I used this enormous tutorial on how to make scrollable text and I didn’t understand half of it and when I implemented the code It didn’t behave they way I wanted it to, soo, 3 hours later and with much less AS (selfproduced this time) I made it and now it works. Thanks for the help.\r\rAchnor

---

<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:** [April 15, 2002, 7:37pm UTC](https://forum.kirupa.com/t/passing-variables-between-movies/2775/8 "2002-04-15T19:37:46Z")

</div>

less code means that less can go wrong.\rglad it works!\r:) \rjeremy
