Be a Supporter!

Browse Sections


Newgrounds Wiki: getMedals

Page Contents

Usage

import com.newgrounds.API;
import com.newgrounds.Medal;

var medals:Array = API.getMedals();
This call returns an array containing Medal instances for every medal in your game.

Examples

The following examples show you how to get your medal list and calculate how many points you have earned by tallying up the medals you have unlocked.

Actionscript 3.0

import com.newgrounds.API;
import com.newgrounds.Medal;

// get the array of medals var medals:Array = API.getMedals();

// set the initial medal score var score:uint = 0;

// read the array for (var i:uint = 0; i < medals.length; i++) { var name:String = medals[i].name; var value:uint = medals[i].value; if (medals[i].unlocked) { trace(name+" is unlocked and worth "+value+" points"); score += value; } else { trace(name+" is not unlocked"); } }

// trace our total medal score for this game trace("You have earned "+score+" medal points in this game!");

Actionscript 2.0

import com.newgrounds.API;
import com.newgrounds.Medal;

// get the array of medals var medals:Array = API.getMedals();

// set the initial medal score var score:Number = 0;

// read the array for (var i:Number = 0; i < medals.length; i++) { var name:String = medals[i].name; var value:Number = medals[i].value; if (medals[i].unlocked) { trace(name+" is unlocked and worth "+value+" points"); score += value; } else { trace(name+" is not unlocked"); } }

// trace our total medal score for this game trace("You have earned "+score+" medal points in this game!");