I'm having trouble setting up communication between two flash files. In the first file I have:
Code:
import flash.events.MouseEvent;
stop();
var mySender:LocalConnection = new LocalConnection();
PlayBtn.addEventListener(MouseEvent.CLICK,clickPla y);
StopBtn.addEventListener(MouseEvent.CLICK,clickSto p);
function clickPlay(Event:MouseEvent){
mySender.send("myConnections", "myAction", 2);
}
function clickStop(Event:MouseEvent){
mySender.send("myConnections", "myAction", 1);
}
And in the second file:
Code:
stop();
var myReceiver:LocalConnection = new LocalConnection();
myReceiver.connect("myConnections");
function myAction(i:int){
if (i == 1) {
DisplayText.text = "STOP!"; //stop();
} else if (i == 2) {
DisplayText.text = "PLAY!"; //play();
}
}
When the Play button is pressed, the second file should display "PLAY!", and likewise with the Stop button. Both files load just fine into a third flash file, but when I try to press either the play or stop buttons, it gives me this:
Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.LocalConnection was unable to invoke callback myAction. error=ReferenceError: Error #1069: Property myAction not found on flash.net.LocalConnection and there is no default value.
Why won't it recognize my "myAction" function?
I'm using ActionScript 3 and CS5.
Thanks!