Ive seen a lot of tutorials but none are really what im looking for. I have a square right now which is saved as troop1_mc. Inside that MC i have a green bar called healthBar_mc.
Pretty much how can I get healthBar_mc to decrease health whether its scaleX or alpha.x or whatever. Ill Attach/copy the applicable code in. It would really help. Im still new to AS3.
THANKS!!!
play_btn.addEventListener(MouseEvent.CLICK, begin);
var infantry:Number = 2; // the speed at which object moves
var infantryHealth:Number = 100;
var healthBar = troop1_mc.healthBar_mc;
function begin (yourEvent:Event):void {
addChild(troop1_mc);
var castleDamage:Number = Math.random() *10;
var castleDamageRounded= Math.round(castleDamage);
troop1_mc.x += infantry;
troop1_mc.addEventListener(Event.ENTER_FRAME, begin)
if (troop1_mc.x >= 300){
troop1_mc.removeEventListener(Event.ENTER_FRAME, begin)
}
//Start Damage
setTimeout(causeDamage,5000);
function causeDamage() {
infantryHealth -= castleDamageRounded;
if (infantryHealth >= -10){
trace(infantryHealth);
troop1_mc.removeEventListener(Event.ENTER_FRAME, begin)
}
removeChild(troop1_mc);
}
play_btn.removeEventListener(MouseEvent.CLICK, begin)
} //Closes function begin