Tuesday, July 31, 2007

Communicate Swf to Swf using Local Connection

here comes the easy way to commnuicate the between swf to swf in the Html
Page.
Add following codes in the Frame Action
reciever.fla
sender.fla
//code for sender
var sender = new LocalConnection();
sendTextToMovieB_btn.onPress=function(){
sender.send('connectionID_movieA_to_movieB','executeOnReceive',input_text.text);
};

/*
Here we sending data action on button named 'sendTextToMovieB_btn' from
the input box value named 'input_text' using local connection 'sender'
*/
//code for receiver
stop();
var receiver = new LocalConnection();
receiver.executeOnReceive = function(receiveText){
display_text.text = receiveText;
};
receiver.connect('connectionID_movieB_to_movieA');
/*
Using the local connection 'receiver' receives the sender data by
executeOnReceive function and assign the receiveText to the dynamic text
named the instance 'display_text'
*/

No comments:

Adobe News