How do you determine when a body is at rest in a loop/hole?

I've created a b2LoopShape that resembles a cup and I shoot golf ball(s) until it/they enter the cup. I want to be able to receive a single notification that the ball has entered and stayed in the cup successfully. I've used the following successfully, but when two balls enter the cup, only one (the smaller one) traces correctly (trace output occurs twice actually). The overridden PreSolve of the b2ContactListener is...

Code:
override public function PreSolve(c:b2Contact, o:b2Manifold):void
      {      
         //8 as index of end of "GolfBall"
         var ballStr = String(c.GetFixtureB().GetBody().GetUserData().costume.name).slice(0, 8);
         
         if (ballStr == "GolfBall" && c.GetFixtureA().GetBody().GetUserData().costume.name == "GroundHole_1")
         {                        
            if (c.GetFixtureB().GetBody().GetLinearVelocity().x == 0 && c.GetFixtureB().GetBody().GetLinearVelocity().y == 0)
            {
               trace("Made " + c.GetFixtureB().GetBody().GetUserData().costume.name + " in the hole!");
            }
         }
         
         super.PreSolve(c, o);
      }


In my testing only the smaller ball seems to reach a LinearVelocity of (0,0), while the contactListener seems to end before the bigger ball reaches a LinearVelocity of (0,0). I tried setting the IsSleepingAllowed boolean of the golf balls to false (in an effort to keep getting contact events), but then the LinearVelocity of neither reaches (0,0). Any ideas or suggestions for better approaches would be much appreciated.

Is there a better way to figure this out? And I've checked, c.GetFixtureB() is always a golfball and c.GetFixtureA() is the "GroundHole_1".
Check out 'sensors' in the documentation. You can have a sensor attached to your cup's body, with the sensor just filling the inside of the cup to see if it intersects with any balls.
I've checked out sensors, and may resort to the idea. But I wan't more to detect if a ball has come to a complete rest within the cup, and not just that it hit the sensor or the cup for that matter. A ball could hit the inside of the cup, but bounce back out, and that is why I'd like to determine if it came to rest inside. Any ideas?
Get a contact with your sensor first, then check if the balls stopped moving.
hit sebsor
inside --> beginContact with sensor
jump out again --> endContact with the sensor
stop moving --> isSleep
Thanks guys. I was going about it the wrong way. I focused way too much on the LinearVelocity of the balls. Thanks again!

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