Problem with a bit of script
So. For some reason the onServerResponse function doesn't run.
Any help appreciated. All the hello traces work by the way.
Code:
trace ("hello")
var service:URLLoader = new URLLoader();
trace ("hello2")
var url:URLRequest = new URLRequest('http://ajax.googleapis.com/ajax/services/search/web');
trace ("hello3")
var urlvars:URLVariables = new URLVariables();
trace ("hello4")
var jsfeed:Object = new Object();
trace ("hello5")
urlvars.v = '1.0';
trace ("hello")
urlvars.q = 'testsearch';
url.data = urlvars;
trace ("hello")
service.addEventListener(Event.COMPLETE, onServerResponse);
service.load(url);
trace ("hello")
function onServerResponse(event:Event):void {
try {
var jsfeed:Object = JSON.decode(URLLoader(event.target).data as String);
var results:Array = json.responseData.results;
for (var i:int = 0; i < results.length; i++){
trace(json.responseData.results[i].titleNoFormatting+" "+results[i].url);
}
}catch(ignored:Error) {
}
}
trace ("hello")