What can cause connection errors when using a bidirectional local connection in Flash?

I am trying to set up a bi-directional local connection (LC) between two flash objects on the same web page. One AS2 object and another AS3.

  • I am using one LC object to send and receive data per SWF. (It shouldn't matter, right? I tried to use two objects, one for sending and one for receiving, but had the same problem).

They .connect () is correct so that they both listen. But I am getting errors when I try to send data from AS2 SWF to AS3 LC. This happens 95% of the time, but sometimes it works, so I know this is not a problem with LC names (I checked, obviously)

Sometimes one or two messages get through and consequtive messages fail.

Any idea what might be causing this?

I'm going to create a one-to-one connection map so that many ASF-swf can connect to one AS3-swf. Will this be a problem?

+1


source to share


3 answers


I finally figured out what was causing the problem.



It looks like while in AS3 you can use the same LC object to send and receive events, AS2 will get errors after a while (perhaps when trying to send after receiving).

0


source


One possible reason is that I noticed that multiple listeners with the same LC name don't seem to work. To see what I mean, open this page in two different tabs and you should see that both "sending" SWFs are working, but the message is received only in the first open tab. I guess you are only using two SWFs, but if they both try to listen to the same LC name, perhaps you are seeing something similar?



Also, I believe that LC is somehow disabled for SWFs that are inside invisible page elements, or perhaps even just behind the scenes. Are you doing something like this?

+2


source


Do you accidentally open two different browsers on the same page? LocalConnection will connect between browsers, which can cause this problem.

Usually what I do to ensure that the LC names are unique is to generate a random LC name on the server and then pass that LC name to both swfs using FlashVars.

It might also have something to do with the order in which the SWF is loaded. It may happen that the swf listening for a connection is loaded after swf creates a connection trying to connect. Then, the other 5% of the time, swf loads in the correct order. Perhaps, if an error occurs, try connecting again.

0


source







All Articles