6 Replies Latest reply on Feb 9, 2009 8:52 AM by mike shry

    LocalConnection from air to as2 flash

    spewky Level 1
      Hello,

      I made a LocalConnection "server" in flash - published for flash player 8, AS2, with the following code:

      var incoming_lc:LocalConnection = new LocalConnection();
      incoming_lc.allowDomain("*");
      incoming_lc.allowInsecureDomain("*");
      incoming_lc.connect("_test");
      incoming_lc.changetext = function(param:String):Void { yourmom.text = param; };

      on the stage there is a dynamic text object instance named "yourmom".

      when I create a flex application with the following MXML and run it inside my browser, the text changes as intended:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
      <mx:Script>
      <![CDATA[

      public function init() : void {
      var outgoing_lc:LocalConnection = new LocalConnection();
      outgoing_lc.send("_test", "changetext", "hello flex world");
      }

      ]]>
      </mx:Script>
      </mx:Application>



      However, the following MXML AIR application silently fails:


      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical" width="600" height="480" creationComplete="init()">
      <mx:Script>
      <![CDATA[

      public function init() : void {
      var outgoing_lc:LocalConnection = new LocalConnection();
      outgoing_lc.send("_test", "changetext", "hello air world");
      }

      ]]>
      </mx:Script>
      </mx:WindowedApplication>


      The only real difference is <mx:WindowedApplication> vs <mx:Application>. Everything happens in file:// context - when I try this on a local webserver, the flex application also silently fails.
        • 1. Re: LocalConnection from air to as2 flash
          spewky Level 1
          Furthermore, when I retarget the server part to AS3, like so:

          function changetext(param:String):void { yourmom.text = param; };
          var incoming_lc:LocalConnection = new LocalConnection();
          incoming_lc.allowDomain("*");
          incoming_lc.allowInsecureDomain("*");
          incoming_lc.connect("_test");
          incoming_lc.client = this;

          and run the server in file:// context, the AIR application gives me this message:
          Error #2044: Unhandled SecurityErrorEvent:. text=Error #2047: Security sandbox violation: LocalConnection.send: app#RgTestControl cannot access file:///tmp/server-as3.swf.

          BUT, when I then put the as3 flash on a local webserver, the AIR application works! Unfortunately, I really need a LocalConnection from AIR to an AS2 file:// ...
          • 2. Re: LocalConnection from air to as2 flash
            spewky Level 1
            Platform information: we observed the "silent fail" part on OSX and XP64.
            • 3. Re: LocalConnection from air to as2 flash
              Damon Edwards Level 3
              I too encountered this problem with no reasonable solution. Since an AIR file has a completely different sandbox, one of application sandbox, communicating via local connection throws the security error. I came to the understanding that if the SWF you want to connect to resides in the application folder, it shouldn't fail to connect, although I haven't tested this.
              • 4. Re: LocalConnection from air to as2 flash
                Oliver Goldman Adobe Employee
                See http://livedocs.adobe.com/flex/3/html/Scripting_and_Communications_1.html for documentation on using LocalConnection in AIR applications.

                Oliver Goldman | Adobe AIR Engineering

                • 5. Re: LocalConnection from air to as2 flash
                  spewky Level 1
                  Oliver - thanks a lot for that information, unfortunately I must admit that I'm still stuck - what should I use as connection name on the flash side of things?
                  I tried using the AIR connection name I determined (which would be
                  app#RgTestControl:_test.7BE97709F73CE28A0B9C046CF1FD1A5E7B590211.1
                  in my case) as well as the old name, both didn't work - and with the AIR connection name, the AS3 server gave me ArgumentError: Error #2004: One of the parameters is invalid. (the AS2 server ran, but didn't work either).
                  • 6. Re: LocalConnection from air to as2 flash
                    mike shry Level 1
                    Did you find a solution to this issue?

                    I am having the same problems, talking to an as2 flash file from AIR. The send from the AIR file fails silently

                    the AS2 file is loaded into the AS3 - AIR application

                    i am also having trouble connecting to an external AS3 file - its ok when in the authoring environment but not in the swf or browser, it gives a security sandbox error


                    if you managed to resolve your issue could you post the solution?
                    or if anyone else has any ideas