View difference between Paste ID: 1dLzxtDc and
SHOW:
|
|
- or go back to the newest paste.
1 | - | |
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:Object):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 | } |