I have a .swf embedded into my php file. I want to click a button in the .swf that Posts a variable, then reloads the php file with the Post method.
As of right now, when I click the .swf button, the browser status bar seems to load something, but the page itself does not refresh.
Is this possible to do?
Here is my PHP code:
if(isset($_POST) && $_POST == 'submitLocation') {
$submitLocation = $_POST['submitLocation'];
echo "Location = ". $_POST['submitLocation'];
}
Here is my Flash code:
function postToPHP () {
var request:URLRequest = new URLRequest ("http://localhost/_myprofile.php");
var loader:URLLoader = new URLLoader (request);
var vars:URLVariables = new URLVariables();
// add the variables to our URLVariables
vars.myLocation = myLocation;
vars.action = "submitLocation";
// send data via post
request.method = URLRequestMethod.POST;
request.data = vars;
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, onComplete);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.load(new URLRequest(request+'?r='+String(Math.random()*9999)));
function onComplete (event:Event):void{
vars.myLocation = myLocation;
trace(loader.data.status);
//navigateToURL(new URLRequest(request+"?submitLocation="+vars.myLocation), "_self");
}
function ioErrorHandler(event:IOErrorEvent):void {
trace("ioErrorHandler: " + event.text);
}