title: AS3 hitTestObject==false
body: <p>I have a life bar in my game and whenever the minion doesn't catch the bananas, the life bar decreases. It works fine, but the problem is that the life bar decreases before it touches the ground. Do I need to add another hitTest in the ground and have it in an &amp;&amp; statement?
  Main program:</p>
  
  <pre><code>import flash.display.MovieClip;
  import flash.events.KeyboardEvent;
  import flash.events.Event;
  
  var leftKey:Boolean;
  var rightKey:Boolean;
  var upKey:Boolean;
  var downKey:Boolean;
  var jump:Boolean = false;
  var xvelocity:int = 9;
  var yvelocity:int = 3;
  var gravity:Number = 7;
  
  
  stage.addEventListener(Event.ENTER_FRAME, changeVelocity);
  stage.addEventListener(KeyboardEvent.KEY_UP, checkKeyUp);
  stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKeyDown);
  
    function changeVelocity(evt:Event){
          moveMinion();
          yvelocity += gravity;
      }
  
      function moveMinion(){
  
          if (leftKey == true){
             sideMinion.x -= xvelocity;
              sideMinion.left();
  
          }
          if (rightKey == true){
              sideMinion.x += xvelocity;
              sideMinion.right();
          }
  
      }
  
      function checkKeyDown(e:KeyboardEvent){
          if (e.keyCode == Keyboard.LEFT){
              leftKey = true;
          }
          else if (e.keyCode == Keyboard.RIGHT){
              rightKey = true;
          }
  
      }
  
      function checkKeyUp(e:KeyboardEvent){
          if (e.keyCode == Keyboard.LEFT){
              leftKey = false;
          }
          else if (e.keyCode == Keyboard.RIGHT){
              rightKey = false;
          }
  
      }
  
      btnStart.addEventListener(MouseEvent.CLICK, makeItFall);
  
      function makeItFall(e:MouseEvent){
  
  
  
      var numBananas = 6;
      var theBananas: Array = new Array();
      theBananas = [];
      for (var i = 0; i &lt; numBananas; i++) {
      var aBanana: banana = new banana();
      theBananas.push(aBanana);
      btnStart.visible=false;
      aBanana.y=100;
      theBananas[i].setSpot(Math.random()*450,Math.random()*200);
      theBananas[i].setSpeed((Math.random()), 1);
      stage.addChild(aBanana);
  
  }   
  
  var health: Number= 100;
  var healthPercent: Number= 1;
  
  addEventListener(Event.ENTER_FRAME, pickUpBananas);
  
  function pickUpBananas(event:Event){
  
      for (var i:int = theBananas.length-1; i&gt;-1; i--){
  
              if (sideMinion.hitTestObject(theBananas[i])){
                  stage.removeChild(theBananas[i]);
                  theBananas.splice(i,1);
  
          }
          else if (sideMinion.hitTestObject(theBananas[i])==false){
              health=health-10;
              healthPercent=health/100;
              trace(healthPercent);
              life.scaleX= healthPercent;
  
          }
      }
  }
  
      }
  
  
  stop();
  </code></pre>
  
  <p>And banana class:</p>
  
  <pre><code>    package {
      import flash.display.MovieClip;
      import flash.utils.Timer;
      import flash.events.TimerEvent;
      import flash.events.MouseEvent;
      import flash.events.Event;
      import flash.events.Event;
  
      public class banana extends MovieClip {
  
          var velX: Number = 0;
          var velY: Number = 0;
          var falling: Boolean = false;
          var gravity: Number = 2;
  
          public function banana() {
              var timing: Timer = new Timer(25, 0);
              timing.addEventListener(TimerEvent.TIMER, moveMe);
              timing.start();
  
          }
  
           private function moveMe(event: TimerEvent)
      {
          x += velX;
          y += velY;
  
          if (falling) velY += gravity;
  
         /* trace("[BANANA] position:", x, y, "speed:", velX, velY);*/
      }
  
  
          public function setSpeed(dx,dy) {
              velX = dx;
              velY = dy;
          }
  
              public function setSpot(atX,atY){
              this.x=atX;
              this.y=atY;
          }
  
  
          public function makeItFall (){
              falling=true;
          }
  
  
      }
  
  }
  </code></pre>