LocalConnection problem

Hello

I have two swf files main.swf and button.swf the button file is loaded into the main file and after loading I am establishing a local connection bw the two so to call methods on each other.

Now the problem is I can work with the local connection fine if i put the localconnection.send method inside a button handler but when I put it directly on the main time line of main.swf file it does work.

Anyone has any idea about the problem. here is the code that I am using

main class


_root.loadMovie("incomingAS2.swf");
// create a new LocalConnection instance used to send
// calls to a LocalConnection instance in another movie
var outgoing_lc:LocalConnection = new LocalConnection();
outgoing_lc.send("lc_example", "methodToExecute", "Hello WOrld");
// event handler when the send button is clicked
/*send_btn.onRelease = function(Void):Void {
 
 // send the methodToExecute method in another movie's
 // LocalConnection listening to "lc_example"
 outgoing_lc.send("lc_example", "methodToExecute", userMessage_txt.text);
}*/

button swf


// create a new LocalConnection instance used to listen
// for calls from a LocalConnection instance from another movie
var incoming_lc:LocalConnection = new LocalConnection();
// create a local connection listening to a connection
// with the name "lc_example"
incoming_lc.connect("lc_example");
// define an method which will be called when a message
// is sent from a LocalConnection instance from another movie
incoming_lc.methodToExecute = function(param:String):Void {
 sentMessage_txt.text = param;
}