flashactionscript-3socketsioerrorxmlsocket

Impossibility to connect to a java server with AS3


I'm having trouble with a XMLSocket script in AS3. I have a java server and i'm trying to send a XML data, but the server isn't recieving anything. The most suprising is that my script worked very well a month ago, and now my IOError listener returns me :

"Error #2031: Socket error. URL: 127.0.0.1 at test() at Client_fla::MainTimeline/frame1()"

and my SecurityError listener :

"Error #2048: Security Sandbox violation : file:///C|/Documents%20and%20Settings/Zeph/Bureau/Client.swf cannot load data from 127.0.0.1:18000. at test() at Client_fla::MainTimeline/frame1()"

I tried to change IP, I tried on another computer, I tried to pull a former version of my script, which was unchanged, with no result.

I just can't understand why it stopped working like this. Here is my script :

package
{

    import flash.net.XMLSocket;
    import flash.events.*;
    import flash.display.MovieClip;

    public class test extends MovieClip 
    {

        public function test()
        {
            trace("pouet");
            var xmlsock:XMLSocket = new XMLSocket(); 
            xmlsock.connect("127.0.0.1", 18000);
            var xmlFormattedData = new XML('<message pseudo="Nix" value="Coucou !"/>'); 
            xmlsock.send(xmlFormattedData);
            xmlsock.addEventListener(DataEvent.DATA, onData);
            xmlsock.addEventListener(IOErrorEvent.IO_ERROR, ioerror);
            xmlsock.addEventListener(SecurityErrorEvent.SECURITY_ERROR, secuerror);
            xmlsock.send(xmlFormattedData);

        }

        private function onData(event:DataEvent):void 
        { 
            trace("[" + event.type + "] " + event.data); 
        }


        private function ioerror(event:IOErrorEvent):void 
        { 
        trace(event);
        }

        private function secuerror(event:SecurityErrorEvent):void 
        { 
        trace(event);
        }

    }

}

I'm getting mad with this, does anyone have an idea?

Thanks for reading!


Solution

  • the error suggests, that you are running a flash application from your local file system and this application wants to make a network request (to your java server).

    This is not allowed by default. You can do one of two things: