00:00
00:00
Newgrounds Background Image Theme

TwistSSD 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: getMedals

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!");