1 Reply Latest reply on Oct 19, 2009 7:33 AM by kglad

    anti hitTest?

    shintashi Level 1

      I've been trying to figure out a way to have movie clip effects only operate WHILE the two objects are colliding with each other. It seems after they collide, however, They no longer need to be in contact to execute the supposedly conditional command. In an attempt to get around "hit Test" I made a fake hitTest, below:

       


          function zone(mc, zquestion){

       

              if(man._y < mc._y +25 && man._y > mc._y -25 && man._x < mc._x +25 && man._x > mc._x -25){
                  mc.onRelease = function(){
                      trace(zquestion);
                  }
              }else { null;}
         
          }
         
         
         
         
         
      onEnterFrame = function(){
         
      zone(block1, "Insert Important Question here?");   
         
         
         
          if(Key.isDown(Key.LEFT)){man._x -= 5;}
          if(Key.isDown(Key.RIGHT)){man._x += 5;}
          if(Key.isDown(Key.UP)){man._y -= 5;}
          if(Key.isDown(Key.DOWN)){man._y += 5;}
         
         
      }

       

      except my attempt at "null/do nothing" if coordinates don't equal all of the above has failed. I really don't understand the "else" command, and would like to know how to create a "if NOT X...then DO NOT do Y".

        • 1. Re: anti hitTest?
          kglad Adobe Community Professional & MVP

          use:

           


           


              function zone(mc, zquestion){

           

                  if(man._y < mc._y +25 && man._y > mc._y -25 && man._x < mc._x +25 && man._x > mc._x -25){
                      mc.onRelease = function(){
                          trace(zquestion);
                      }
                  }else { delete mc.onRelease;}
             
              }
             
             
             
             
             
          onEnterFrame = function(){
             
          zone(block1, "Insert Important Question here?");   
             
             
             
              if(Key.isDown(Key.LEFT)){man._x -= 5;}
              if(Key.isDown(Key.RIGHT)){man._x += 5;}
              if(Key.isDown(Key.UP)){man._y -= 5;}
              if(Key.isDown(Key.DOWN)){man._y += 5;}
             
             
          }

           

          except my attempt at "null/do nothing" if coordinates don't equal all of the above has failed. I really don't understand the "else" command, and would like to know how to create a "if NOT X...then DO NOT do Y".