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!

How to Have a Flash Button Activate Another .swf File? 1

Status
Not open for further replies.

bsquared18

Technical User
Jun 10, 2001
329
US
Hi,

I have a .swf file of an animation that automatically begins when the web page the .swf file is on is loaded. I no longer have the original .fla file (sob!).

Is there code to put on a button in a different .swf file to activate the .swf file described above? If possible, both .swf files would be on the same web page near each other, and the action would look the same as if the button and the other animation were in the same file.

Thanks!
Bill
 
Kenneth,

Thanks. I did a little research on LocalConnection.

The code below is from an example outgoing file that on button release sends a user-typed message to another, incoming file.

//assign a function to the button's event method
buttonInstance.onRelease = function() {
//create the LocalConnection by first
//setting it equal to a variable
outgoing_lc = new LocalConnection();
//send the contents of the text field
//using the send() method
outgoing_lc.send("lc_name", "methodToExecute", userMessage.text);
//delete the local connection now that the
//message has been sent
delete outgoing_lc;
};

How would I change this code to have the button activate the other .swf file instead of sending it a message?

Thanks!
Bill
 
It depends on what you mean by "activate", but let's assume you want the receiving SWF to start playing.

You can keep your code in the sending SWF, but remove the parameter as you're not sending the message. So it would be:
Code:
...
outgoing_lc.send("lc_name", "methodToExecute");
...
In the receiving SWF you can define "methodToExecute" in any way you like, but in this case it'll be just "play()".
Code:
var receiving_lc:LocalConnection = new LocalConnection();
receiving_lc.methodToExecute = function() {
	play();
};
receiving_lc.connect("lc_name");
It also should have "stop()" in the first frame otherwise it just starts playing without any interaction.

Kenneth Kawamoto
 
I see. My problem is that I no longer have the Flash version of the file to put the incoming message into. Can I simply embed the .swf file in a new Flash file and go from there?

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top