Skip navigation
jo23jo
Currently Being Moderated

Sandbox error on URLRequest to php file

Oct 26, 2011 10:40 AM

I 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.

 
Replies
  • Currently Being Moderated
    Nov 15, 2011 8:32 PM   in reply to jo23jo

    You're trying to run in Adobe Flash or browser, if the SWF in the browser has to be in the same domain of PHP, as this is a security lock for chance try running via "Desktop" "C:".

     

     

    The swf should be within the site that is PHP.


     
    |
    Mark as:
  • Currently Being Moderated
    Nov 15, 2011 8:36 PM   in reply to jo23jo

    You're trying to run in Adobe Flash or browser, if the SWF in the browser has to be in the same domain of PHP, as this is a security lock for chance try running via "Desktop" "C:".

     

     

    The swf should be within the site that is PHP.


     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points