1
votes

I'm trying to setup a bidirectional localConnection (LC) between two flash objects on the same web page. One object is AS2 and the other AS3.

  1. I'm using one LC object to send and receive data on each swf. (This shouldn't matter, right? I tried using two objects, one for sending and one for receiving, but got the same problem).

They .connect() properly so that they both listen. But I'm getting errors when I'm trying to send data from the AS2 SWF to the AS3 LC. This happens 95% of the time, but sometimes it DOES work, so I know it's not a problem with the LC names (I checked, obviously)

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

Any idea on what might cause it?

I'm aiming to create a many-to-one connection map so that many AS2 swfs could connect to the one AS3 swf. Will that be a problem?

3

3 Answers

2
votes

One possible cause is that I've noticed that multiple listeners to the same LC name seem not to work. To see what I mean, open this page on two different tabs, and you should see that both of the "sending" SWFs work, but the message is only received on the first tab you opened. I guess you're only using two SWFs, but if they're both trying to listen to the same LC name, perhaps you're seeing something similar?

Also, I believe LC is, in some way, disabled for SWFs that are inside invisible page elements, or possibly even just offscreen. Are you doing anything like that?

0
votes

You don't by chance have two different browsers open to the same page do you? LocalConnection will connect across browsers which may cause that issue.

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

It may also have something to do with the order in which the swf's load. It may be that the swf listening for the connection is loading after the swf creating the connection tries to connect. Then, the other 5% of the time, the swf's load in the correct order. Maybe if an error occurs, just try to connect again.

0
votes

I finally figured out what caused the problem.

It seems that although in AS3 you can use the same LC object to send AND receive events, doing so in AS2 will give you errors after a while (probably when trying to send after receiving).