views:

475

answers:

1

I'm developing a Adobe Air application that should make use of a SWF file using LocalConnection.

I've never used LocalConnection before, but from what I understood from the online reference, I need to specify the same connection name on both the sender and the receiver.

Since I don't have access to this component source code, how can I find out what connection name should I use?

I do have access to some JavaScript files that use the same SWF, but since I have no experience with JavaScript I wouldn't know where to start looking for. Could I figure something out from there?

... or am I missing something?

+2  A: 

There is no way to query from ActionScript what the connectionName is. The reason being it would open up a myriad of security holes. If this is mentioned in the documentation of the SWF you want to talk to -- check it out.

The whole LocalConnection business, though not difficult, is complicated by the fact that the documentation is flaky, to say the least. And very, very confusing. You should read it very carefully before attempting to do anything. I've burnt my fingers there.

Check this out first:

  • Is the AIR app on different computer than the SWF? You're out of luck otherwise. Because:

    LocalConnection objects can communicate only among files that are running on the same client computer [...]

  • Does the SWF have a LocalConnection object? If no, you're out of luck.

  • Your AIR app (assuming it the callee, and invokes some method X on the SWF) needs to have a LocalConnection object as well. And, it will have to call connect() to connect to the SWF.
  • Your best bet is to take the last approach mentioned in the documentation, (which is also the most generic) i.e. Different domains with unpredictable domain names. Also, to start off allow any and every domain so use: allowDomain(*);
  • If the other SWF is also an AIR application you will have to prepend the application ID to the connection name.

Now, give it your best shot and let us know where you get stuck. Best of luck!

dirkgently
Thanks! I've mailed the guys responsible for the SWF asking the connection name. After that I don't think it will be much of a problem. The SWF will be on the same computer as the Air app. I'll let you know how everything went out after that.
leolobato
That sounds good to me. Best of luck!
dirkgently