View Full Version : Passing variables between movies
Achnor
April 14th, 2002, 01:35 PM
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).
How do I do this?
This is the AS in m1:
on (release) {
        docufield = "background.txt";
}
And this is the AS in m2:
this.loadVariables(docufield);
Achnor
ilyaslamasse
April 14th, 2002, 01:49 PM
2 movie clips or 2 swf ?? Cos you can't load variables from a swf (nor from a movie clip by the way...).
pom 0]
Achnor
April 14th, 2002, 01:50 PM
two swf...it can't be done?
Here's the full story:
I 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.
Achnor
sinfiniti
April 14th, 2002, 03:07 PM
you just have to target the variable properly.
whether you loaded into a target or a level you have to path to that clip.
example:
if you loaded the 2 swf's into levels 1 and 2 respectively the paths would be something like this...
_level1.myVariable
_level2.myVariable
if you loaded into targets named mc1 and mc2 the paths would look like this...
_level0.mc1.myVariable
_level0.mc1.myVariable
or...
_root.mc1.myVariable
_root.mc2.myVariable
when swf's are loaded into other swf's they are basically movie clips and can be targeted as such.
:)
jeremy
Achnor
April 14th, 2002, 04:33 PM
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:
onClipEvent (load){
        this.loadVariables(docufield);
}
it wont load data.txt. Can't I use variables this way?
Achnor
sinfiniti
April 14th, 2002, 06:28 PM
it should work. i did a test and it was fine.
test your movie and then go to 'debug' and 'list variables'. you should see the variables that were loaded in the output window.
:)
jeremy
Achnor
April 15th, 2002, 02:49 PM
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.
Achnor
sinfiniti
April 15th, 2002, 03:37 PM
less code means that less can go wrong.
glad it works!
:)
jeremy
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.