contact Listener- some questions

okay thanks for reading.
below is my code for the begin contact function of the contactListener class.
have a read of that then these are my questions:

do i have to check if the contact is touching ?
if i dont do this will i get contacts that are just aabb overlaps ?

notice how I check if the bullet is either A or B
so I have to code everything twice.
is that how this should be coded ? is there a better way to do this so I dont have to double up code ?

thanks


Code:
public virtual function BeginContact(contact:b2Contact):void {
         var A=contact.GetFixtureA().GetUserData();
         var B=contact.GetFixtureB().GetUserData();
         if (contact.IsTouching()) {
            if (A is bullet) {
               if (B is player) {
                  trace("trace the bullet hit the player")
               }
            }
            if (B is bullet) {
               if (A is player) {
                  trace("trace the bullet hit the player")
               }
            }
         }


      }
I cannot remember if you get empty contacts. I think so. Best experiment.

You can give a canonical ordering to your bodies, and then "sort" your contact so that the lower body is always before the larger one. For example, you could give each body a unique integer in it's user data, then check:

if(bodyA.GetUserData() as int > bodyB.GetUserData() as int)
{
// Swap the two bodies
}
thank you boris!

Original thread: https://box2d.org/forum/viewtopic.php?t=4561