I set up something using almost the same exact code as something else I got to establish communication between the flash file and a php file. But for some reason it’s not working now. But the other one works, and the code is pretty much the same…
AS3:
submit_btn.addEventListener(MouseEvent.CLICK, submit);
function submit(event:Event):void {
var variables:URLVariables = new URLVariables();
var varSend:URLRequest = new URLRequest("http://mysite/config_flash.php");
varSend.method = URLRequestMethod.POST;
varSend.data = variables;
var varLoader:URLLoader = new URLLoader;
varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader.addEventListener(Event.COMPLETE, completeHandler);
variables.sendRequest = "parse";
// Send the data to the php file
varLoader.load(varSend);
// When the data comes back from PHP we display it here
function completeHandler(event:Event):void{
var phpVar1 = event.target.data.win;
if(phpVar1 == "1"){
message_txt.text = "Your submission has been successfully added!";
} else {
message_txt.text = "Your submission failed";
trace(phpVar1);
}
}
}
PHP:
<?php
if ($_POST['sendRequest'] == "parse") {
print "win=1";
}
?>
Yet every time I try it outputs the error message in the text field and the trace returns a undefined variable.