flash/passing variables
- Started
- Last post
- 9 Responses
- fitsum
Need help on passing variables from the main swf to a swf that loads inside it.
- ethios0
Can you not just set _root.var and access it from the SWF?
- fitsum0
the swf that plays inside the main swf has lockroot set to true. THis cannot change. wouldnt I have to say parent._root or something?
- jpea0
can you do _global.myVar = ... ?
- thirtytwo0
What about passing the values from one MC to another using Arrays
thisMC.movie = new Array(myValue1,myValue2);
then grab them...
newVal1 = movie[index++];
newVal2 = movie[index++];Hope this helps, let me know
if you need an example...cheers,
mark
- SmilingBuddh0
Are you using loadMovie, or loadMovieNum?
If you're losing loadMovie, just use the name of the target that you're loading into.
ie. holder_mc.var = value;
If you're using loadMovieNum, you can target the level of the movie
ie. level1.var = value;
It sounds to me like you are using loadMovie; so just think of the .swf that is being loaded in as the MC that it was loaded into.
- fitsum0
I'm using loadMovie() and doing the "holder_mc.var=value;" but I'm thinking bc the swf that loads into holder_mc has lockroot set to true that it's fowling things up.
- fitsum0
gonna give it a shot, jpea
- fitsum0
unfortunately none of the above is working. for some reason, the swf that is loaded iside the main swf cant get access to the variable I'm trying to set from the main swf.
I'm pretty sure it's because of the lockroot - which if I set to "false" will cause things to not work - but am going to make sure
- SmilingBuddh0
Are you setting the variable, then loading the movie?
Or loading the movie, then setting the variable?
If you are setting first, this is the problem - the var will be cleared when the movie loads. So, you can either set the variable in a _level0 based holder object:
1. ---
in main.swf:
var_obj = {};
var_obj.varname = value;in your other .swf
level0.var_obj.varname
2. ---
Alternately, you can use a MovieClipLoader to load the movie into the holder, and use it's onLoadInit listener. This is more complicated but a bit more sound code-wise:
var mcl = {};
mcl.onLoadInit = function() {
holder_mc.varname = value;
};var my_loader = new MovieClipLoader();
my_loader.loadClip("myswf.swf", holder_mc);Hope that helps.