Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending values between swfs 1

Status
Not open for further replies.

sandravega

Programmer
Feb 10, 2004
43
AR
Hi
Here´s my goal:

I have a swf (intro1.swf) that calls another swf when the user releases a button, the code:

on (release) {
loadMovie("intro2.swf?idioma=ESP", 0);
}

of course, this unloads intro1.swf and loads intro2.swf.
I believe that there's a way to read that variable "idioma" from intro2.swf, but I don't know how and if it is possible, I don't know where should I put the script

Thank you everybody

Sandra
 
First, if loading on a level (as you're doing!), the correct syntax would be:

on (release) {
loadMovieNum("intro2.swf", 0);
}

Not you could pass that variable from one movie to the other by simply using _global...

on (release) {
_global.idioma = "ESP"; // I gather it's a string...
loadMovieNum("intro2.swf", 0);
}

Then in the second movie...

trace(_global.idioma);
Or...
my_2ndmovie_var = _global.idioma;


 
You can also pass the variables in the loadMovieNum statment:

Code:
on(release){
   idioma = "ESP";
   loadMovieNum("intro2.swf",0,"POST");
}

In the loaded swf refer to the variable as _root.idioma.

Wow JT that almost looked like you knew what you were doing!
 
Hey... uh... neither methods seem to work.
In both cases, I get a simphatetic "undefined" where I trace the _global.idioma or the _root.idioma value

Is there something else that I should know?


Sandra
 
oldnewbie:
Thanks again. (I loved your little three-eyed face)
Your example works, mine don´t. Is it necesary to let 15 frames or more to run before asking the value of the variable?

Maybe that´s it.

Sandra
 
I think the problem may be that for both methods you must have something physically in the first movie. If you just have the loadMovie Command on the first frame and nothing on the stage it does not work. (not really sure why but that seems to be the case)

Another example:
Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Still works if I remove all but the actionscript!

May I ask what would be the point in loading empty movies?
Anyways, they're not empty... They hold actionscript.
 
Now, sorry: my swf was being exported as Flash 5. I think THAT was the problem

Sandra

(I solved it in flash 5 version using a level0 empty mc that loads intro1 in level1, then intro1 loads intro2 also in level1, and the level0 empty mc holds the vars. That works for 5, and for 6 and further your example works just fine. I didn't try pixl8r with flash 6, but I assume that it works too...)

thank you very much again
 
Old I think you need to re-read my post. I didn't suggest that you should load empty movies. Even though I can think of a reason that someone might want the stage their initial movie to be empty.

For whatever reason my testing (MX Pro) was not working if I had nothing on the stage of the first movie. Once I placed something on the stage it worked just fine.

I do not remember this being a problem in previous versions of flash, so it might be an MX 2004 thing. (One i'm sure would hardly ever come up since as you say... who needs an empty movie).

I hope that clears up any questions.

Glad you got it to work Sandy!


Wow JT that almost looked like you knew what you were doing!
 
I did read your post, and what caught my eye was...

...be that for both methods you must have...

Just wanted to clear that out!

And although I didn't try it, I still have doubts about one referencing the variable to _root (rather than a global one), when using loadMovieNum especially loading a new movie on _level0...

 
Pardon.

Obviously I mis-spoke based on problems I seem to be having with 2004.

No offense was intended.



Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top