NaN:NaN
NaN:NaN
--:-- / --:--
Newgrounds Background Image Theme

TheafterWeirdio just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Browse Sections

Newgrounds Wiki: getScoreBoard

Page Contents

import com.newgrounds.API;
import com.newgrounds.ScoreBoard;


var board:ScoreBoard = API.getScoreBoard(board_name:String);
import com.newgrounds.API;
import com.newgrounds.APIEvent;
import com.newgrounds.ScoreBoard;
import com.newgrounds.Score;


// this function will run when the server returns our list of scores
function onScoresLoaded(event:APIEvent):void {
    if (event.success) {
        var board = event.data.board;


        for(var i:uint=0; i<board.scores.length; i++) {
            var score:Score = board.scores[i];


            trace(score.position+": "+score.username+" -- "+score.value);
        }
}


// Tell the api to listen for the SCORES_LOADED event
API.addEventListener(APIEvent.SCORES_LOADED, onScoresLoaded);


// get our board and tell it what time period to load up, and how many results
var high_scores:ScoreBoard = API.getScoreBoard("High Scores");
high_scores.period = "Today";
high_scores.num_results = 20;


// load the scores from the server
high_scores.loadScores();
  • Actionscript 2.0
import com.newgrounds.API;
import com.newgrounds.APIEvent;
import com.newgrounds.ScoreBoard;
import com.newgrounds.Score;


// this function will run when the server returns our list of scores
function onScoresLoaded(event:APIEvent) {
    if (event.success) {
        var board = event.data.board;


        for(var i:Number=0; i<board.scores.length; i++) {
            var score:Score = board.scores[i];


            trace(score.position+": "+score.username+" -- "+score.value);
        }
}


// Tell the api to listen for the SCORES_LOADED event
API.addEventListener(APIEvent.SCORES_LOADED, onScoresLoaded, this);


// get our board and tell it what time period to load up, and how many results
var high_scores:ScoreBoard = API.getScoreBoard("High Scores");
high_scores.period = "Today";
high_scores.num_results = 20;


// load the scores from the server
high_scores.loadScores();