Playing an animation after killing a mob?

Hey guys once again i need the help of this wonderful community. My question is as follows,

i have it set up so that a bunch of mobs come to the player and the player needs to kill them,so i want it so when you kill the last guy it triggers an animation. please help so that i may proceed with my game thanks in advance!

The algorithm i can think of is to:

1.Create PlayAnimation.js. apply this to the object with the animation.

static var nMobs:int; //holds the amount of killed mobs.
var totalMobs:int = 10; //Total number of mobs.
    function Update() {
          if (nMobs ==totalMobs ){
             animation.Play("nameOfTheAnimation"); //Play desired animation.
             nMobs = 0; //prevent from playing animation every frame.

2.Create CountMobs.js. apply this to your mobs prefab. I assume that a single collision could kill them.

function OnCollisionEnter(collision : Collision) {
    //you can use the collision information stored in the collision variable to verify the correct hit. you may learn that here: [Collision][1]
    PlayAnimation.nMobs++; //Adds 1 to the number of killed mobs in the first script.