0

I am building an AIR application using AIR 3.1 that is trying to connect to a local http socket using

    localhost:7676  

The socket is being run from an OSX application on the same computer that the AIR app is trying to connect to using localhost. Upon successful connection the AIR app is supposed to receive a JSON string of data.

When running the swf in a browser, I connect using localhost:7676 there is no issue, it connects successfully to the OSX app running the socket. When the FlashBuilder project is packaged up and compiled as an AIR app, and I connect using the same address, I get this error, and don't know how to resolve...

* Security Sandbox Violation * Connection to localhost:7676 halted - not permitted from app:/Matrx_Remote_App.swf SecurityError: Error #2147: Forbidden protocol in URL localhost:7676

The code that I am using in the class is just a simple loader class

    _loader = new URLLoader();

        var request:URLRequest = new URLRequest("http://localhost:7676");
        _loader.addEventListener(Event.COMPLETE, onComplete);
        _loader.addEventListener(IOErrorEvent.IO_ERROR, ioerrorHandler);
        _loader.addEventListener(flash.events.HTTPStatusEvent.HTTP_RESPONSE_STATUS, handleOnEventStatus);
        _loader.load(request);

And the onComplete method looks like this:

    private function onComplete(e:Event):void {
        trace("e " + URLLoader(e.target).data +  _loader.data + " _loader.bytesTotal " + _loader.bytesTotal);
        var loader:URLLoader = URLLoader(e.target);
        var jsonData:Object  = JSON.parse(loader.data);
        trace(jsonData);

    }

ANY help on this would be greatly appreciated, thanks!

bolnad
  • 4,533
  • 3
  • 29
  • 41
  • you can find an answer here: http://stackoverflow.com/questions/304271/security-sandbox-in-as3 – Eran Jun 07 '12 at 05:31
  • Are you running the air app on the same machine that is works on? – The_asMan Jun 07 '12 at 07:21
  • I am running the air app on the same machine, that is correct. – bolnad Jun 07 '12 at 13:40
  • @Eran thanks for the response - I added the -use-network=false to the Additional Compiler Arguments in the Properties of the Flash Builder project and I still get the same message. Any other ideas? – bolnad Jun 08 '12 at 02:13
  • You're loading a local file, something that's not permitted. However, as you're developing this you can of course allow this. Add your project folder to the trusted locations: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html – Eran Jun 10 '12 at 06:34
  • this is an AIR app and I don't think the same rules apply, as I tried that and it didn't work – bolnad Jun 13 '12 at 22:01

1 Answers1

0

Update to this question.... AS it turns out, it was a problem with the way the socket was written and had nothing to do with the client side, thanks to everyone who took the time to help

bolnad
  • 4,533
  • 3
  • 29
  • 41