How to create a leaderboard in your Flash game with Scoreoid

Emanuele Feronato Actionscript 3, Flash, Game design

Some days ago I showed you how to save and show the best score in your game with Scoreoid.

Now it’s time to make something more interesting, such as a top 5 leaderboard. If you followed the first step, you should know one of the best Scoreid features is there isn’t any SDK since the Scoreoid Open Web API is based on the standard RESTful HTTP/HTTPS protocol.

Anyway, this is the new version of the game, with the top 5 at the bottom right of the stage:

You know how to play: mouse button to turn on engines, avoid the squares, collect the circles and travel as far as you can. Notice the leaderboard in the bottom right corner.

I just created another sprite called Leaderboard with a dynamic text in it, and made some changes to the main class. In the script, I highlighted the changes from the previous version.

As you can see, it’s just a matter of using getScores() method to retrieve a number (requestVars.limit) of game scores ordered by a desired way (requestVars.order_by) in a particular order (requestVars.order).

You will get an XML like this one:

Which is pretty easy to parse by loaderCompleteHandler function. Refer to understanding AS3 and XML if you don’t know how to parse XML.

And that’s another great Scoreoid feature unveiled, next time I am going to show you even more.

No need to download anything, just copy/paste this code in the file you can get from the original prototype, just remember to use your own game id and api key.

Comments 4

Leave a Reply

Your email address will not be published. Required fields are marked *