I'm lying in bed on the lappytop right now, so this is all pseudocode, but let's see if we can't get you set in the right direction.
First of all, have a look through the testbed/example folder, and you'll find a little function (input.as?) called getbodyatmouse...
Now I'm assuming you have some sort of implementation of this that returns say
myBody:b2Body
and you have the variables
physMouseX:Number = mouseX / 30; (where 30 is the default physics scale)
physMouseY:Number = mouseY / 30;
multiplier:Number = 50; /// how hard you wanna shove the object
Now, to push the object away from the mouse...
we need to find out how far the mouse is from the center of the object, vertically and horizontally...
so xDistance = myBody.GetPosition().x - physMouseX;
& yDistance = myBody.GetPosition().y - physMouseY;
and
xForce = xDistance * multiplier;
yForce = yDistance * multiplier;
So the force applied is based on the distance from the center of the object... kinda like tiddlywinks.. and we get this
myBody.ApplyImpulse( new b2Vec2( xForce, yForce ) , new b2Vec2(0,0) );
or
myBody.ApplyForce( new b2Vec2( xForce, yForce ) , new b2Vec2(0,0) );
(assuming 0,0 is the center of the object... i.e. objects' center, not world center so a circle's center might be 0,0 while it's coords were x=20.4 and y=15)
You can kinda refine that into a single line if you feel like it:
Code:
public function clicky(){
var physMouseX:Number = mouseX / 30;
var physMouseY:Number = mouseY / 30;
var myBody:b2Body;
var multiplier:Number = 50; //more than sufficient for an impulse
myBody = GetBodyAtMouse(); // find this in your test folder..
if (myBody != null)
myBody.ApplyImpulse(
new b2Vec2(
(myBody.GetPosition().x - physMouseX) *multiplier ,
(myBody.GetPosition().y - physMouseY) *multiplier
),
new b2Vec2( 0,0)
);
}//clicky
Again, that's completely off the top of my head, so don't be surprised if it doesn't even begin to compile, but the concept seems solid.