# \[AS2\] Communication between 2 SWF Files

**URL:** <https://forum.kirupa.com/t/as2-communication-between-2-swf-files/267850>\
**Category:** flash\
**Created:** [August 6, 2008, 1:56pm UTC](https://forum.kirupa.com/t/as2-communication-between-2-swf-files/267850 "2008-08-06T13:56:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![erikcute](https://avatars.discourse-cdn.com/v4/letter/e/6bbea6/32.png) [@erikcute](https://forum.kirupa.com/u/erikcute)\
**Post date:** [August 6, 2008, 1:56pm UTC](https://forum.kirupa.com/t/as2-communication-between-2-swf-files/267850/1 "2008-08-06T13:56:41Z")

</div>

Hi! I’m trying to control the animation between 2 SWF files contained on a same webpage.

SWF-1 should pause its animation upon reaching a certain frame and play SWF-2. Then SWF-2 should also pause its animation upon reaching a certain frame and should play SWF-1 from where it paused.

I managed to establish the connection from SWF-1 to SWF-2 and its working up to this point.

This is the action on the first frame of SWF-1:

```auto
//code going to Movie 2
mysender_2 = new LocalConnection();
 
//code coming from Movie 1 
myReceiver_1 = new LocalConnection();
myReceiver_1.connect("myConnection_1"); 
myReceiver_1.doAction_1 = function(doThat_1) {
if (doThat_1 == 1) {
        play();
    } else if (doThat_1 == 2) {
        stop();
    } else if (doThat_1 == 3) {
        gotoAndPlay(210);
}
};

```

Then this is the action that triggers SWF-2 to play

```auto
myReceiver_1.connect("myConnection_1");
onEnterFrame = function ()
{
    mysender_2.send("myConnection_2", "doAction_2", 1);
};

```

At this point the connection is successful…however, I used the same code structure for SWF-2 to trigger SWF-1 but I don’t know why it won’t work.

This is the action on the first frame of SWF-2:

```auto
stop();
//code coming from Movie 2 
myReceiver_2 = new LocalConnection();
myReceiver_2.connect("myConnection_2"); 
myReceiver_2.doAction_2 = function(doThat_2) {
if (doThat_2 == 1) {
        play();
    } else if (doThat_2 == 2) {
        stop();
}
};
 
//code going to Movie 1
mysender_1 = new LocalConnection();

```

Then this is the action that should trigger SWF-1 to play from where it paused

```auto
myReceiver_2.connect("myConnection_2");
onEnterFrame = function ()
{
_root.mysender_1.send("myConnection_1", "doAction_1", 3);
};

```

I really need help coz I’m running out of ideas :crying:
