I am having a problem on my latest project that i am doing.I am creating a platform game with multiple enemy,what i want is every enemy have health.My enemy is created from another class like this.
function addEnemy(xLocation:int, yLocation:int):void
{
var enemy:Enemy = new Enemy(xLocation, yLocation);

this.addChild(enemy);

enemy.addEventListener(Event.REMOVED, enemyRemoved);
enemyList.push(enemy);

}
i want something like this to happen.
if(enemyList[m].hitTestObject(hero.hitBox)){
enemyList[m].health-=2;
}
But i its not working even i try this on addEnemy function:
enemy.health=10;
I am really trying to have all of them have seperate health value but i cant do it what should i do?