# Local connection not communicating button states! Help!

**URL:** <https://forum.kirupa.com/t/local-connection-not-communicating-button-states-help/216137>\
**Category:** flash\
**Created:** [February 14, 2007, 12:49am UTC](https://forum.kirupa.com/t/local-connection-not-communicating-button-states-help/216137 "2007-02-14T00:49:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Head\_In\_A\_Pan](https://avatars.discourse-cdn.com/v4/letter/h/c67d28/32.png) [@Head\_In\_A\_Pan](https://forum.kirupa.com/u/Head_In_A_Pan)\
**Post date:** [February 14, 2007, 12:49am UTC](https://forum.kirupa.com/t/local-connection-not-communicating-button-states-help/216137/1 "2007-02-14T00:49:36Z")

</div>

Hey!  
I’ve been trying to get my two swfs to talk - Not working.  
I want them to react to each other as if they were one swf - ie if a button is highlighted in swf 1 and then a button is selected in swf 2 I want the first button to fade & the new button to highlight. Does that make sense?

Here’s my code - if anyone can see anything obviously wrong please let me know!  
Swf 1

```auto

var an_lc:LocalConnection = new LocalConnection();
var toggle:Boolean = true;
an_lc.setState = function(state:Boolean):Void {
    toggle = !toggle;
    curBtn(toggle);
};
an_lc.connect('connection2');

var lastClicked = null;

function onClick()
{
    an_lc.send('connection', 'setState', toggle);
    lastClicked(!toggle);
    toggle = !toggle;
    if ( this.select = !this.select ) {
        this.gotoAndStop( "released" );
        lastClicked.gotoAndPlay( "out" );
        lastClicked.select = false;
        lastClicked = this;
    } else {
        this.gotoAndPlay( "out" );
        lastClicked = null;
    }
}

function overOut()
{
    this.over = !this.over;
    if (!this.select ) this.gotoAndPlay( ( this.over ) ? "over" : "out" );
}

//////////////////////////////////////////

for (var i=1; i<10; i++)
{
    var curBtn = this["b" + i];
    
    curBtn.over = false;
    curBtn.select = false;
    
    curBtn.onRelease = onClick;
    curBtn.onRollOver = curBtn.onRollOut = curBtn.onReleaseOutside = overOut;
};
function lastClicked(state:Boolean):Void {
    curBtn = state ? "over" : "out";
}

```

swf 2

```auto

var an_lc:LocalConnection = new LocalConnection();
var toggle:Boolean = false;
an_lc.setState = function(state:Boolean):Void {
    toggle = !toggle;
    curBtn(toggle);
};
an_lc.connect('connection');

var lastClicked = null;

function onClick()
{
    an_lc.send('connection2', 'setState', toggle);
    lastClicked(!toggle);
    toggle = !toggle;
    if ( this.select = !this.select ) {
        this.gotoAndStop( "released" );
        lastClicked.gotoAndPlay( "out" );
        lastClicked.select = false;
        lastClicked = this;
    } else {
        this.gotoAndPlay( "out" );
        lastClicked = null;
    }
}

function overOut()
{
    this.over = !this.over;
    if (!this.select ) this.gotoAndPlay( ( this.over ) ? "over" : "out" );
}

//////////////////////////////////////////

for (var i=1; i<10; i++)
{
    var curBtn = this["b" + i];
    
    curBtn.over = false;
    curBtn.select = false;
    
    curBtn.onRelease = onClick;
    curBtn.onRollOver = curBtn.onRollOut = curBtn.onReleaseOutside = overOut;
};

function lastClicked(state:Boolean):Void {
    curBtn = state ? "over" : "out";
}

```
