ActionScript Leaderboards


The previous tutorial taught you how to create a Leaderboard and Event that submits your player's score. Now you can incorporate them into your ActionScript project.

For this tutorial, we've created a sample game that runs for 10 seconds. In those 10 seconds:

Setting up the Event Log Request

Creating the Message Handler

Testing the Leaderboard

Example ActionScript Leaderboard code can be downloaded here

Setting up the Log Event Request

You'll need a function that calls the Event that submits the player's score:

if (endTime <= now)
        requestBuilder.createLogEventRequest().setEventKey("LEADERBOARD_SCORER").setNumberEventAttribute("SCORER", Score).send(ScoreResponse);
        RestartBtn.enabled = true;
        logger("Times up");

Setting up the Message Handlers

Once you've set your LogEventRequest to upload the player's score, you can now set up a NewHighScoreMessage handler. Handlers are very useful tools, which allow you to intercept messages that are passed in to your authenticated player.

For this tutorial, we'll be dealing with NewHighScoreMessage.


Create the function which deals with the message. The parameters of the function would take a variable of type NewHighScoreMessage. This function allows you to simplify the structure of the message and access some useful data.

In this tutorial, we retrieve the Leaderboard's name to show the highscore message as an alert.

        private function HighScoreMessageListener(message:NewHighScoreMessage):void
          "You achieved the highscore in the leaderboard: " + message.getLeaderboardName(), "High Score Alert")

Testing the Leaderboard

Run your game and try to beat the high score. If you do, you'll receive a message informing you that you have beaten the high score in that Leaderboard.


Did this page help you? Please enter your feedback below. For questions about using this part of the platform, please contact support here