move my body ;)

I'm completely new in using the Box2D for flash AS3 and i finally managed to get the body thing to work. But if i want to control a body using thekeyboard i have absolutely no clue on how to tap in to the position Box2D gives the body.

any suggestions on how i can move my body? hehe
Might want to check out Using a body in the manual. Examples are given in C++, but shouldn't be too hard to figure out. Here's a quick example in AS3 though:

Code:

myBody.WakeUp();
myBody.applyImpulse(new b2Vec2(100,0),myBody.GetCenterPosition());



That will push the body 100 units to the right. The first value is x, 2nd is y. As you may know, y is positive to go down and negative to go up in Flash. The second parameter is where you apply the impulse at, which is the center of mass of the body. There is more detail in the manual.
thanx... but i need to identefie the wakeUp function. what shoud i identefie it as? var wakeUp: ? ;
sory if that's a stupid question but im also very new to AS3.
WakeUp() is a member function of a b2Body. It's type is "Function" but you don't need to identify it unless you are creating a reference to that function. Creating a reference to a function is a useful feature, but I don't know why you would need to do that with this function...
it gives me this error messege: 1061: Call to a possibly undefined method WakeUp through a reference with static type PlayerClass. 😐
It sounds like you are trying to call WakeUp on one of your custom classes. You can't call WakeUp directly from your class, because that method belongs to b2Body. You need to abstract the functions you want your player class to perform. So you might have a function to move your player left/right/whatever. The player class will store a reference to it's b2Body, and you will call WakeUp() and ApplyImpulse(), etc... (any other functions that need to be called on the body) from within the player class.

You should really take some time to get familiar with AS3 before you dive into using a physics engine.

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