wrong script
It is not working because it checks the health condition only once, but it must check about 24 times per second (or what is your framerate)
the script will look like:
onEnterFrame=function(){
if (_root.HP==0) { gotoAndPlay("lose");
}else if (_root.enemyHP==0) { gotoAndPlay("win"); }
}