Retrieving variables from PHP.
Hi! I've just started to learn AS3 and I found out that I had to use some new methods to retrieve data from PHP. And now (of course) it doesn't work :p
My AS3 code looks like this:
Quote:
//Create the URLLoader instance
var myLoader:URLLoader = new URLLoader()
//the data will come as URL-encoded variables
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES
//Load using an URLRequest, even beeing local
myLoader.load(new URLRequest("http://magnusvs.net/flashgalleri/connectToDb.php"))
//onLoad handler listener
myLoader.addEventListener(Event.COMPLETE, onDataLoad)
//add a listener for the complete event
function onDataLoad(evt:Event){
if(evt.target.data!=""){
trace(evt.target.data["id0"]);
}
}
The structure of the string that the php code echoes is like this:
Quote:
&id0=1&navn=asdasd&id1=1&navn=dffhr
When I run the AS3 code, I get this error code:
Quote:
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$iinit()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()
If I remove
Quote:
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES
and just trace (not a specific variable), I get the entire output, but just as a string ofcourse...
Does anybodt know how I can retrieve separate variables/being able to loop through the output variable by variable?