Just wanted to create a topic for people to post helpful bits of code, or download links for larger chunks. I thought of this because I saw people talking on here about limiting the speed of objects, but I never saw any code (unless I missed it). Well it's not too complicated, but for really common stuff like this I figured it might at least save someone a little time. Also it's interesting to see how people do things differently.
Code:
//assuming you have the following variable that actually contains a b2Body
var body:b2Body;
//and a speed limit, I think this may depend on the mass of your object
var speedLimit:Number;
var bodyVelocity:b2Vec2 = body.GetLinearVelocity();
if (bodyVelocity.Length() > speedLimit) {
var limitVelocity:b2Vec2 = bodyVelocity.Copy();
limitVelocity.Normalize();
limitVelocity.Multiply(speedLimit);
var velocityDifference:b2Vec2 = bodyVelocity.Copy()
velocityDifference.Subtract(limitVelocity);
body.ApplyImpulse(velocityDifference.Negative(),body.GetCenterPosition());
}