Custom Search

Communicate Flash Movie using LocalConnection Class

Macromedia Flash has a special class called LocalConnection that allows you to communicate between swf that resides on the same client machine and on the same domain but are performing different operation. This is useful in a scenario where you want to pass data from one swf to another without using JavaScript.





Methods used in LocalConnection Class:

This method will send the data between the swf. The Local Connection Name refers to the name of the localconnecion Object. The method name refers to the function that will be called after successful sending the data.

This method will try to connect to the swf having the Local Connection Name specified in the argument.

This method closes/destroys the localconnection object.

Typical Example:
Suppose i have two Flash Movie Movie1 and Movie2 and you want to send data from Movie1 to Movie2

Action Script Code for Move1 on the first frame:

sender = new LocalConnection();
sender.send(”connection1″, “connection_method”,data);

Action Script Code for Move2 on the first frame:

reciever = new LocalConnection();
reciever.connection_method = function(x)
{
trace(x);
};
reciever.connect(”connection1″);

Similar Posts

Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.

Comments

No comments yet.

Leave a comment

(required)

(required)