I've got some strange stuff going on. I have a SWF that is hosted on server A. I have a php file on server B that processes forms. My SWF sends form information to server B and expects to get a set of variables returned (form processed successfully or not).
The SWF is built in AS3. The code is written like this:
Code:
// SEND FORM INFO
//-- collect variables
var variables:URLVariables = new URLVariables();
variables.email = txtEmail.text;
//-- set up request for URL
var myRequest:URLRequest = new URLRequest();
myRequest.url = "https://services.processingserver.com/postdata/";
myRequest.method = URLRequestMethod.POST;
myRequest.data = variables;
//-- process loader
var myLoader:URLLoader = new URLLoader();
//myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
try
{
myLoader.load(myRequest);
}
catch (error:ArgumentError)
{
trace("An ArgumentError has occurred.");
txtPrompt.text = "SERVER ARGUMENT ERROR";
}
catch (error:SecurityError)
{
trace("A SecurityError has occurred.");
txtPrompt.text = "SERVER SECURITY ERROR";
}
myLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS,httpStatusHandler);
myLoader.addEventListener(IOErrorEvent.IO_ERROR,errorHandler);
myLoader.addEventListener(Event.OPEN, openHandler);
myLoader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
myLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
myLoader.addEventListener(Event.COMPLETE,completeHandler);
....
function securityErrorHandler(e:SecurityErrorEvent):void
{
txtPrompt.text = "SERVER SECURITY ERROR - "+e.text;
}
It works fine when I test it from a local file. However, when I post the form SWF to the live server, it returns an Error #2048, triggered by the securityErrorHandler function.
The remote server has a crossdomain.xml file, and the server that the SWF is posted on has the file too. This is the code in the xml file:
Code:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy
SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" secure="false"/>
</cross-domain-policy>
I've tried adding this code to the SWF:
Code:
Security.allowDomain("*");
Security.loadPolicyFile("https://services.processingserver.com/crossdomain.xml");
What am I doing wrong?
Best,
--eric