# LocalConnection problem

**URL:** <https://forum.kirupa.com/t/localconnection-problem/276025>\
**Category:** Uncategorized\
**Created:** [November 21, 2008, 12:41pm UTC](https://forum.kirupa.com/t/localconnection-problem/276025 "2008-11-21T12:41:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![adnan794](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@adnan794](https://forum.kirupa.com/u/adnan794)\
**Post date:** [November 21, 2008, 12:41pm UTC](https://forum.kirupa.com/t/localconnection-problem/276025/1 "2008-11-21T12:41:03Z")

</div>

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

```auto

_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

```auto

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

```
