Contact Yart for a relaxed conversation
Your Name * Message *
Your Email *  
Your Phone   
Our Phone:        03 8685 8718 (within Australia)
61 3 8685 8718 (outside Australia)
Contact Yart

Melbourne Content Management and Flash developers

 

for designers, agencies and your website

Resources / Flash / Communicating between SWFs
Communicating between SWFs

You can send data from a Flash SWF file to another, no matter if either or both of them are ActionScript 2 or ActionScript 3.

Here is an example of sending a message from an AS2 SWF to an AS3 SWF.
In this example we will use the connection name "lc_example" and method name "methodToExecute". These names can be changed.

Receiving in AS3

Put the following code in your .as file.

In the import section:

import flash.net.LocalConnection;

In the top of the class:

var incoming_lc:LocalConnection = new LocalConnection();

In the constructor:

  incoming_lc.connect("lc_example");
  incoming_lc.client = this;

Add this function to the class:

  public function methodToExecute(param:String):void
  {
      trace("received");
      // Do whatever you want here...
  }

Sending in AS2

Put this code in a function to send the message

  var outgoing_lc:LocalConnection = new LocalConnection();
  outgoing_lc.send("lc_example", "methodToExecute", userMessage_txt.text);

 

For a complete tutorial on this click here.

The latest at Yart
Search: