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

Lizdoll111 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: unlockMedal

Page Contents

import com.newgrounds.API;
API.unlockMedal(medal_name:String, popup_x:Number, popup_y:Number);
import com.newgrounds.API;
import com.newgrounds.APIEvent;
import com.newgrounds.Medal;


// This function will fire when the unlockMedal command is called
function onMedalUnlocked(event:APIEvent):void {
    if (event.success) {
        // get the medal instance
        var medal:Medal = event.data.medal;


        // trace out what medal was unlocked, and how many points it is worth.
        trace("You unlocked '"+medal.name+"'! (value: "+medal.value+" points)");
    }
}


// tell the API to use the above listener when a medal is unlocked.
API.addEventListener(APIEvent.MEDAL_UNLOCKED, onMedalUnlocked);


// Unlock the medal
API.unlockMedal("My Medal");
  • Actionscript 2.0
import com.newgrounds.API;
import com.newgrounds.APIEvent;
import com.newgrounds.Medal;


// This function will fire when the unlockMedal command is called
function onMedalUnlocked(event:APIEvent) {
    if (event.success) {
        // get the medal instance
        var medal:Medal = event.data.medal;


        // trace out what medal was unlocked, and how many points it is worth.
        trace("You unlocked '"+medal.name+"'! (value: "+medal.value+" points)");
    }
}


// tell the API to use the above listener when a medal is unlocked.
API.addEventListener(APIEvent.MEDAL_UNLOCKED, onMedalUnlocked, this);


// Unlock the medal
API.unlockMedal("My Medal");