Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Scott Cariss

By: a guest on Nov 4th, 2010  |  syntax: ActionScript 3  |  size: 1.51 KB  |  hits: 40  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Load High scores from server
  2. var hiscoreloader:URLLoader = new URLLoader();
  3. hiscoreloader.addEventListener(Event.COMPLETE, highScoresLoaded);
  4. hiscoreloader.load(new URLRequest("http://wfwxg.philosophydesign.com/includes/top20.php?nocache=" + new Date().getTime()));
  5.  
  6. // Create an Array to hold High Score XML data
  7. var highscoredata:Array = [];
  8.  
  9. //
  10. var hiscorexml:XML;
  11. function highScoresLoaded(e:Event):void
  12. {
  13.         hiscorexml = new XML(e.target.data);
  14.         var hsList:XMLList = hiscorexml.highscores.highscore;
  15.         for(var i:uint = 0; i < hsList.length(); i++)
  16.         {
  17.                 highscoredata[i] = {
  18.                                                                 hs_score : zeroPad(hsList.score.text()[i], 8),
  19.                                                                 hs_name : hsList.name.text()[i],
  20.                                                                 flagURL : "http://wfwxg.philosophydesign.com/images/flags/" + hsList.country.text()[i] + ".png",
  21.                                                                 mc_name : "hs_flag_"+i.toString()
  22.                                                          };
  23.                 // Load the Flag images
  24.                 var loader:Loader = new Loader();
  25.                 configureFlagListeners(loader.contentLoaderInfo);  
  26.                 loader.name = i.toString();
  27.                 loader.load( new URLRequest( highscoredata[i].flagURL ) );
  28.         }
  29. }
  30. function configureFlagListeners(info:LoaderInfo):void
  31. {
  32.         info.addEventListener(Event.COMPLETE , completeFlagHandler );
  33. }
  34. function removeFlagListeners(info:LoaderInfo):void
  35. {
  36.         info.removeEventListener(Event.COMPLETE , completeFlagHandler );
  37. }
  38. function completeFlagHandler(event:Event):void
  39. {
  40.         var index:int = int( event.currentTarget.loader.name );
  41.         highscoredata[index].flag = event.currentTarget.loader.content;
  42.         removeFlagListeners(event.currentTarget);
  43. }