title: as3 Error #2048: Security sandbox violation when trying to connect through socket
body: <p>I have a SWF file embedded in a PHP web application. All local and on my system. I want to make a socket connection from my SWF to localhost:4242 (which is an eye tracker api). When I run SWF using flash player everything works fine. But when I run it from browser I get:</p>
  
  <pre><code>Security Error: [SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048: Security sandbox violation: http://localhost/graph/assets/swf/Graph.swf cannot load data from http://localhost:4242."]
  </code></pre>
  
  <p>I added crossdomain.xml to my local web server (<a href="http://www.easyphp.org" rel="nofollow">easy php</a>) like this:</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
    &lt;cross-domain-policy&gt;
    &lt;site-control permitted-cross-domain-policies="master-only"/&gt;
    &lt;allow-access-from domain="*" to-ports="*" secure="false"/&gt;
    &lt;allow-http-request-headers-from domain="*" headers="*"/&gt;
  &lt;/cross-domain-policy&gt;
  </code></pre>
  
  <p>and this is my action script for socket connection:</p>
  
  <pre><code>socket = new Socket();
  Security.allowDomain("*");
  Security.allowInsecureDomain("*");
  Security.loadPolicyFile("http://localhost/crossdomain.xml");
  socket.addEventListener(Event.CONNECT, onSocketConnect);
  socket.addEventListener(Event.CLOSE, onClose);
  socket.addEventListener(IOErrorEvent.IO_ERROR, onError);
  socket.addEventListener(ProgressEvent.SOCKET_DATA, onResponse);
  socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecError);
  
  socket.connect("http://localhost", 4242);
  </code></pre>
  
  <p>I went through everything on web for solving this problem. I don't know what the problem is and what should I do.</p>