I was wondering if some one could explain how I can read a MySQL result array in AS3.
I am using:
var loader:URLLoader = new URLLoader();
var urlReq:URLRequest = new URLRequest("http://domain.com/get-api.php");
var urlVars:URLVariables = new URLVariables();
loader.dataFormat = flash.net.URLLoaderDataFormat.TEXT;
urlReq.method = URLRequestMethod.POST;
urlReq.data = urlVars;
urlVars.mySubmittedRateID = GlobalVariables.mySubmittedRateID;
urlVars.myPostcode = GlobalVariables.currentPostcode;
loader.addEventListener(flash.events.Event.COMPLETE, getDataOnComplete);
loader.load(urlReq);
to pass a parameter (2 in fact) to the get-api.php file. In the file I PHP reading in the parameters and a normal SQL select where statement which gets all the results matching the parameters.
My getDataOnComplete function is:
private function getDataOnComplete(event:flash.events.Event):void
{
var loader:URLLoader = new URLLoader(event.target);
var resultsArray:Array = JSON.decode(loader.data);
}
My PHP:
$row_array['done'] = "true";
return json_encode($row_array);
Error:
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
at Error$/throwError()
at flash.net::URLVariables/decode()
at flash.net::URLVariables()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
For some reason I cant even get to the getDataOnComplete function.