Data Realms Fan Forums
http://45.55.195.193/

Problem with a bit of script
http://45.55.195.193/viewtopic.php?f=7&t=12190
Page 1 of 1

Author:  AtomicTroop [ Thu Sep 04, 2008 7:36 am ]
Post subject:  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")

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/