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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending variables from one flash to another? 1

Status
Not open for further replies.

whoknows361

Technical User
Sep 22, 2005
228
US
Hey all.
Here's my goal? I want, when a user clicks on a certain button, that a new browser window opens containing an .swf movie, and that .swf movie loads certain (pics, text, etc) dependent on the variables sent from the original flash movie.

Here's what I've tried so far:
on sending .swf:
Code:
target_mc.onPress = function() {
		getURL("matchdisplay.htm", "_blank");
	}
	target_mc.onRelease = function() {
		sending_lc = new LocalConnection();
		sending_lc.send("lc_name", "methodToExecute", match2bigpic[_root.itemchoicenumber]);
	}

and on receiving swf:
Code:
receiving_lc = new LocalConnection();
receiving_lc.methodToExecute = function(bigpic){
	trace(bigpic);
}
receiving_lc.connect("lc_name");

Doesn't seem to work - in fact, I'm not sure if I should be using this format, or something like the loadVars.

And if I use the LoadVars - I know how to send the variables I want to the php script - but then how do I get the php script to: 1) open the new browser window with my swf in it 2) send the varialbes to this new .swf movie 3) and how do I get my newly opened .swf movie to load these variables into the individual mc's I want them to.

I hope this makes sense

Jonathan
 
When you open a new window and send a LocalConnection call, your receiving SWF is not yet initialized therefore cannot receive the call.

One way is to append your variable as a query string when opne a new window. Something like:

[tt]getURL("matchdisplay.htm?bigpic=" + match2bigpic[_root.itemchoicenumber], "_blank");[/tt]

Then use Javascript in the opened window to write FlashVars which passes the variable to the receiving SWF.

Kenneth Kawamoto
 
could you help me out with what the javascript might look like? How do I write javascript to "write FlahVArs"?

Thanks Kennneth

Jonathan
 
nevermind, what I did was had the loading .swf be the sender and it sent back to the .swf that loaded it. When the original .swf received the command (which indicated that second .swf as initated) - then it created a new local connection object which then sent the variables.

Works great.

Thanks Kenneth
 
Huh? how did you get that to work do you have a simple, sample?
 
this code on movie one:
Code:
target_mc.onPress = function() {
		getURL ("javascript:NewWindow=window.open('matchdisplay.htm','newWin','width=600,height=400,left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No');  NewWindow.focus();      void(0);");
		receiving_lc = new LocalConnection();
		receiving_lc.methodToExecute = function(ready) {
			if (ready == "yes") {
				sending_ll = new LocalConnection();
				sending_ll.send("ll_name", "myMethod", match1bigpic[_root.itemchoicenumber], match1description[_root.itemchoicenumber], match1price[_root.itemchoicenumber], match1fulldescription[_root.itemchoicenumber], description[_root.itemchoicenumber]);
			}}
		receiving_lc.connect("lc_name");
	}

and this code on movie 2:
Code:
sending_lc = new LocalConnection();
sending_lc.send("lc_name", "methodToExecute", "yes");

receiving_ll = new LocalConnection();
receiving_ll.myMethod = function(bigpic, description, price, fulldescription, previtem) {

//actions to be completed //


}
receiving_ll.connect("ll_name");

Hope that helps

Jonathan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top