# Need Help! AS2 FLASH 8 if inside function

**URL:** <https://forum.kirupa.com/t/need-help-as2-flash-8-if-inside-function/324175>\
**Category:** Uncategorized\
**Created:** [August 6, 2011, 12:53pm UTC](https://forum.kirupa.com/t/need-help-as2-flash-8-if-inside-function/324175 "2011-08-06T12:53:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ikirily](https://avatars.discourse-cdn.com/v4/letter/i/58f4c7/32.png) [@ikirily](https://forum.kirupa.com/u/ikirily)\
**Post date:** [August 6, 2011, 12:53pm UTC](https://forum.kirupa.com/t/need-help-as2-flash-8-if-inside-function/324175/1 "2011-08-06T12:53:16Z")

</div>

Please help… this is for my thesis…

PROBLEM: I don’t know what’s the reason why in the first if block statement of this function “if(\_root.hp\_mc.\_width \< 10){” after the condition get satisfied once, the next turn it would satisfy again, the variable life and heart didn’t reduce to 1…

|| i have a life\_mc1,life\_mc2,life\_mc3 = a graphical representation of remaining life which should be redue/hide one by one if the first if condition will be satisfied… and when the life is less than 0 the game will be over… please help me…

```auto
    
function hpLife(){ // health bar subtraction
        _root.hp_mc._width = (_root.hp_mc._width - subHealth);
    // Heart subtraction
        if(_root.hp_mc._width < 10){
            _root["life_mc" + heart]._visible = false;
            _root.hp_mc._width = 127;
            maxHealth = 127;
            life--;
            heart--;
    // Life Number Subtraction    
            if(life < 4){
                gotoAndStop("control");
            }
        }
    }
    var heart:Number = 3; //Used as life_mc1, life_mc2, life_mc3....
    var life:Number = 4; // Used as starting Life
    var maxHealth:Number = _root.hp_mc._width(); //Used as HP BAR
    var subHealth:Number = 31.75; //Used to Subtract HP BAR

```
