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
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
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";
}