PDA

View Full Version : passing variables between .swf's



balned
May 11th, 2002, 12:48 PM
Hello all, I have a bit of a problem. I'm trying to get one movie to send a variable to another movie. I was hoping someone could show me how to check the string that's being sent, and have the movie do stuff based on what string is being sent (if (string=="bla"){gotoAndPlay("bla");}. Thanks in advance.

flatline damnation
May 15th, 2002, 06:19 AM
I believe that what you're trying to achieve is called XML.
Unfotunately, I'm not at all an expert in this field, but you can try doing something like this:

Link from the origin swf:
getURL("<a href="http://www.yoursite.com/name.swf?variable=value");">www.yoursite.com/name.swf...e=value");</a>

I don't know if that'll work, because flash files work differently when not embeded into html pages. So your question interests me as well.

upuaut8
May 15th, 2002, 07:50 AM
hmm.. doesn't seem like it should be that hard to do.. XML shouldn't be necessary.. though I'm not posative off the top of my head. Would both swf's be open on the same screen of the same computer? If not.. like you want two different comps to talk to each other then yeah XML socket is the way to go.. if it's just one movie telling another what to do.. that's a little different.

balned
May 15th, 2002, 11:04 AM
Thanks for the reply. Here's a more detailed description of th problem:

I have 2 movies, each in a separate frame; 'left' and 'main'. The 'left' frame is the navigation console, which is going to update the 'main' frame when a user hits a button. For a coulple of the pages I've embeded an .swf as the content of 'main'. I need someway for the nav .swf to communicate with the 'main' .swf. I am using an fscommand to JS to pass a variable (myVar) from 'left' to 'main'. Currently, myVar is passed to 'main', but I am unable to check the variable. I can only display it in a text box. So I know it's being passed to the movie, but what I need to do is be able to read the variable, and based on the contents of said variable perform the proper action;if (myVar=="training"){gotoAndStop("training");}, or something to that effect.

flatline damnation
May 17th, 2002, 02:04 PM
I'm shooting in the dark here, but did you manage to achieve it using this?:

Button Action on nav.swf:

on(Release){
getURL("menu.swf?myVariable=training");
}

According to what upu said, it should work...

upuaut8
May 17th, 2002, 10:26 PM
I think that will work.. ?myVariable=something at the end of an address should send that variable along to the swf that you're loading.