I have the crossdomain.xml in domain root.
It’s readable and valid.
I am using port 80.
In AS3, I am using:
Security.loadPolicyFile(“http://www.site.com/crossdomain.xml”);
<?xml version=“1.0” encoding=“UTF-8”?>
<!DOCTYPE cross-domain-policy SYSTEM “http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd”>
<cross-domain-policy>
<allow-access-from domain="" to-ports="" />
<site-control permitted-cross-domain-policies=“master-only”/>
</cross-domain-policy>
I still get the following error when I run flash in Adobe flash CS4. Also, it doesn’t work from web either. All params are correct. Flash loads. etc.
I did this too:
In the Flash editor, File->Publish Settings… click on the Flash tab and change Local playback security to Access Network Only.
I read zillions of posts online, but still helpless…any more idea? thank you.
securityErrorHandler: [SecurityErrorEvent type=“securityError” bubbles=false cancelable=false eventPhase=2 text=“Error #2048: Security sandbox violation: file:///C|/Users/me.Desktop/me.swf cannot load data from www.site.com:80.”]
This is my code:
package {
import flash.display.Sprite;
public class HttpRequestor extends Sprite {
public function HttpRequestor() {
var socket:CustomSocket=new CustomSocket("www.site.com",80);
}
}
}
import flash.errors.;
import flash.events.;
import flash.net.Socket;
import flash.net.sendToURL;
import flash.net.URLRequest;
import flash.system.Security;
Security.loadPolicyFile(“http://www.site.com/crossdomain.xml”);
//Security.allowDomain("");
//Security.allowInsecureDomain("");
class CustomSocket extends Socket {
private var response:String;
public function CustomSocket(host:String = null, port:uint = 0) {
super(host, port);
configureListeners();
}
private function configureListeners():void {
addEventListener(Event.CLOSE, closeHandler);
addEventListener(Event.CONNECT, connectHandler);
addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);
}
private function writeln(str:String):void {
str+="
";
try {
writeUTFBytes(str);
} catch (e:IOError) {
trace(e);
}
}
private function sendRequest():void {
trace("sendRequest");
response="";
writeln("GET /");
flush();
}
private function readResponse():void {
var str:String=readUTFBytes(bytesAvailable);
response+=str;
}
private function closeHandler(event:Event):void {
trace("closeHandler: " + event);
trace(response.toString());
}
private function connectHandler(event:Event):void {
trace("connectHandler: " + event);
sendRequest();
}
private function ioErrorHandler(event:IOErrorEvent):void {
trace("ioErrorHandler: " + event);
}
private function securityErrorHandler(event:SecurityErrorEvent):void {
trace("securityErrorHandler: " + event);
}
private function socketDataHandler(event:ProgressEvent):void {
trace("socketDataHandler: " + event);
readResponse();
}
}