Hey guys!
I have a simple script that sends a variable to php (locally) and then php returns another variable to flash…
Here’s the simple script:
var variables:URLVariables = new URLVariables();
var varSend:URLRequest = new URLRequest("http://localhost/test/test.php");
varSend.method = URLRequestMethod.POST;
varSend.data = variables;
var varLoader:URLLoader = new URLLoader;
//varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader.dataFormat = URLLoaderDataFormat.TEXT;
varLoader.addEventListener(Event.COMPLETE, completeHandler);
variables.action = "submitForm";
varLoader.load(varSend);
function completeHandler(event:Event):void
{
trace("works");
trace(event.target.data);
var checkStatus:String = event.target.data.imdoneUpdate;
trace(checkStatus);
if (checkStatus == "1")
{
trace("WORKS");
}
else
{
trace("NEEEEEEH");
}
}
PHP CODE:
$action=$_POST['action'];
if ($action == "submitForm")
{
$imdoneUpdate = true;
echo "imdoneUpdate=".$imdoneUpdate;
}
flash output:
works
imdoneUpdate=1
ReferenceError: Error #1069: Property imdoneUpdate not found on String and there is no default value.
at test_fla::MainTimeline/completeHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
As you can see…flash is connecting to php and even the trace for event.target.data is tracing imdoneUpdate=1 …so why event.target.data.imdoneUpdate is not properly working??
Am I echoing incorrectly through php?
Thanks a lot in advance!