LocalConnection to run a function in another .swf not working....
SeanPercy42 Aug 10, 2013 8:58 PMI'm trying to establish a LocalConnection so that I can communicate between my navbar & the main page on my website. Here is the code I have so far for the sending and receiving AS3 files, please let me know if you see anything out of the ordinary. The idea is that when you click on one of the icons on the navbar my "book" slides down to the center of the screen on the correct page. I actually have 4 buttons but only included the code I'm using for two in order to make this post shorter. The same idea is used for all four buttons though.
Sending:
var sending_lc:LocalConnection;
sending_lc = new LocalConnection();
servicesBtn.buttonMode = true;
portfolioBtn.buttonMode = true;
function servicesBtnOver(event:MouseEvent):void{
servicesBtn.gotoAndPlay('over');
}
function servicesBtnOut(event:MouseEvent):void{
servicesBtn.gotoAndPlay('out');
}
function servicesBtnClick(event:MouseEvent):void{
sending_lc.send("my_lc_as3", "gotoServicesPage");
}
servicesBtn.addEventListener(MouseEvent.ROLL_OVER, servicesBtnOver);
servicesBtn.addEventListener(MouseEvent.ROLL_OUT, servicesBtnOut);
servicesBtn.addEventListener(MouseEvent.CLICK, servicesBtnClick);
function portfolioBtnOver(event:MouseEvent):void{
portfolioBtn.gotoAndPlay('over');
}
function portfolioBtnOut(event:MouseEvent):void{
portfolioBtn.gotoAndPlay('out');
}
function portfolioBtnClick(event:MouseEvent):void{
sending_lc.send("my_lc_as3", "gotoPortfolioPage");
}
portfolioBtn.addEventListener(MouseEvent.ROLL_OVER, portfolioBtnOver);
portfolioBtn.addEventListener(MouseEvent.ROLL_OUT, portfolioBtnOut);
portfolioBtn.addEventListener(MouseEvent.CLICK, portfolioBtnClick);
Receiving:
import com.greensock.*;
import com.greensock.easing.*;
var receiving_lc:LocalConnection;
receiving_lc = new LocalConnection();
receiving_lc.connect("my_lc_as3");
receiving_lc.client = this;
var bookPosition:String = "up";
function gotoServicesPage(event:MouseEvent):void {
book.gotoAndStop('webDesignPage');
}
if (bookPosition == "up");
{
TweenLite.to(book, 2, {y:830});
var bookPosition == "down";
}
}
function gotoPortfolioPage(event:MouseEvent):void{
book.gotoAndStop('porftolioPage');
if (bookPosition == "up");
{
TweenLite.to(book, 2, {y:830});
var bookPosition == "down";
}
}
The reason I'm keeping track of whether the book is in the "up" or "down" is so that if it's in the down position already it doesn't re-tween back onto the screen. I am new to declaring and using variables; TweenLite; and LocalConnection so there is probably some simple problem with my AS3 code (although no errors are coming up in Flash). Any help would be much appreciated.

