Sandbox error on URLRequest to php file
jo23jo Oct 26, 2011 10:40 AMI am running into an issue with passing variables from Actionscript 3 to PHP.
This is a very basic program just for testing purposes to find out if this will work.
Here is the Actionscript 3 coding (One button named 'btn_Submit' and one text box named 'txt_User' are on the stage).
This is a very simple attempt to input text into an 'Input Text Box', upon pressing a submit button, it should pass the text to a php file named 'test.php'.
The .swf file and the test.php files are both located in the same directory on my webserver (main directory for subdomain 'www.testing.budgetmylife.net')
For the URLRequest parameter, I have even tried just ("test.php"), without success:
*************************************************
import flash.events.*
import flash.net.*;
var myVariables:URLVariables = new URLVariables();
var myLoader:URLLoader = new URLLoader();
var myRequest:URLRequest = new URLRequest("http://www.testing.budgetmylife.net/test.php");
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
myRequest.method = URLRequestMethod.POST;
btn_Submit.addEventListener(MouseEvent.CLICK, SubmitHandler);
function SubmitHandler(e:MouseEvent):void {
myVariables.username = txt_User.text;
myRequest.data = myVariables;
myLoader.load(myRequest);
}
**************************************************
Simple php script in file 'test.php':
*******************************************
<?php
$username = $_POST['username'];
echo "Name: ".$username;
?>
When the flash project is run, it allows me to enter a name, but once submit is clicked, the following error occurs:
Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: file:///C|/Users/John/AppData/Local/Temp/2%2Dtest.swf cannot load data from http://www.testing.budgetmylife.net/test.php.
at test_fla::MainTimeline/frame1()
Please assist......After reading many forums and tutorials, I was assuming this may have been a crossdomain issue.
I followed some online instructions to place a file named 'CrossDomain.xml' on my webserver.
CrossDomain.xml contents:
*********************************************
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="master-only" />
<allow-access-from domain="testing.budgetmylife.net" />
<allow-http-request-headers-from domain="*" headers="*" secure="false"/>
</cross-domain-policy>
************************************************
This did nothing to resolve the issue.
My goal is to actually pass variables to a php file, run some sql (which I have no issues doing), then send results back to the flash program.
I wanted to make sure the variables were being passed to the php file before I went any further, so this is where I am stuck.
I will hopefully not have an issue passing the variables back as I am aware of the syntax to use in the php file to send the variables and how to obtain them in the Actionscript 3 code.
Once I get the above working properly, I will hopefully not have an issue.
