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