Getting information from php file
The output of my php file looks like this:
[{"id":2,"name":"NRK MP3","url":"http:\/\/lyd.nrk.no\/nrk_radio_mp3_mp3_m","country_id":37},{"id":72,"name":"Radio Loland","url":"http:\/\/stream.radiololand.no:5000\/loland128","country_id":37}]
What i want to accomplish is to get that information, I need the url, the country id, the name, and the id. But I get this 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 DatabaseTest_fla::MainTimeline/onCompleteHandler()[DatabaseTest_fla.MainTimeline::frame1:28]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
If I change my php file to this. It works
<?php
echo "values=8";
?>
My As3 code:
import flash.events.MouseEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLVariables;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequestMethod;
import flash.events.Event;
var myLoader:URLLoader = new URLLoader();
myLoader.dataFormat = URLLoaderDataFormat.TEXT;
var myRequest:URLRequest=new URLRequest("mydomain.com/something.php");
myLoader.load(myRequest);
myLoader.addEventListener(Event.COMPLETE,onCompleteHandler);
var myValue: String;
function onCompleteHandler(e:Event):void{
var myvariable: URLVariables = new URLVariables(e.target.data);
myValue = myvariable.values;
trace(myValue);
}