Last Updated: February 25, 2016
·
1.859K
· darshanrane

AS2, AS3 Communication using Local Connection

ActionScript Virtual Machine that runs AS3(AVM2) and AS2(AVM1) are completely different from each other, so both the swf’s cant communicate with each other.

The LocalConnection Class have a common implementation in both the virtual machines. The LocalConnection class lets you create a LocalConnection object that can invoke a method in another LocalConnection object.

The communication can be:

Within a single SWF file

Between multiple SWF files

Between content (SWF-based or HTML-based) in AIR applications

Between content (SWF-based or HTML-based) in an AIR application and SWF content running in a browser

For setting up communication between AS2 and AS3 Swf, we need to create a sender and receiver in both the swfs. In the example here we will pass a text value from respective swf to another swf. A AS2 swf is loaded within AS3 swf.

<a href="http://darshanrane.com/rnd/as2-as3-communication/src.rar">Source Code</a>