1 Reply Latest reply: Feb 5, 2014 10:33 AM by svincs RSS

    LocalConnection - Adobe ActionScript® 3 (AS3 ) API Reference

    Community Help Community Member
        • 1. Re: LocalConnection - Adobe ActionScript® 3 (AS3 ) API Reference
          svincs

          Before you use this Object you HAVE TO see this:

           

          SWF to SWF on different domains

           

          Based on apps nature – for generic/unknown domains you can use super generic form (works for every combination domain/swf/air). Notice the underscore character “_” with connection name:

           

          // SWF receiver on unknown domain

          localConnection.allowDomain("*");

          localConnection.connect("_connectionName");

           

          // SWF sender on unknown domain

          sendingLC.send("_connectionName", "methodName");

          … or more secure version, where you define exactly the domain you are targeting:

           

          // SWF receiver on domain1.com

          localConnection.allowDomain("domain2.com");

          localConnection.connect("connectionName");

           

          // SWF sender on domain2.com

          localConnection.send("domain1.com:connectionName", "methodName");

          AIR to SWF

           

          Now its getting tricky, please focus. Air app calls method on swf on some exact domain:

           

          // SWF receiver on domain1.com

          localConnection.allowDomain("app#SENDERAIRID"); // e.g. "app#sk.yoz.air.SenderApp"

          localConnection.connect("connectionName");

           

          // AIR sender

          localConnection.send("domain1.com:connectionName", "methodName");

          … or the same super generic method mentioned earlier for unknown/generic receiver swf file location

           

          // SWF receiver on unknown domain

          localConnection.allowDomain("*");

          localConnection.connect("_connectionName");

           

          // AIR sender

          localConnection.send("_connectionName", "methodName");

          SWF to AIR

           

          … now the opposite standing air receiver and swf sender:

           

          // AIR receiver

          localConnection.allowDomain("domain1.com");

          localConnection.connect("connectionName");

           

          // SWF sender on domain1.com

          localConnection.send("app#RECEIVERAIRID:connectionName", "methodName");

          // e.g. "app#sk.yoz.air.ReceiverApp:connectionName"

          … or use super generic form:

           

          // AIR receiver

          localConnection.allowDomain("domain1.com");

          localConnection.connect("_connectionName");

           

          // SWF sender on domain1.com

          localConnection.send("_connectionName", "methodName");

          AIR to AIR

           

          This one is hefty, make sure to substitute with correct ids:

           

          // AIR receiver (sk.yoz.air.ReceiverApp)

          localConnection.allowDomain("app#SENDERAIRID"); // e.g. "app#sk.yoz.air.SenderApp"

          localConnection.allowDomain("localhost"); // may help with local testing

          localConnection.connect("connectionName");

           

          // AIR sender (sk.yoz.air.SenderApp)

          localConnection.send("app#RECEIVERAIRID:connectionName", "methodName");

          // e.g. "app#sk.yoz.air.ReceiverApp:connectionName"

          … or once again the generic form, now possible even without allowDomain()

           

           

          // AIR receiver

          localConnection.connect("_connectionName");

           

          // AIR sender

          localConnection.send("_connectionName", "methodName");