skin dynamic body

Hello everyone,

I'm pretty new to AS3 and I've just started to try box2d 2.1a by making a game. I understand the basic principles (create world, body, debug draw, etc..), but there's just one thing I can't figure out.

I'm trying to "attach" a movieclip to several dynamic bodies. Every second a new body is created and I attach a movieclip to it. If the bodies are static everything works just fine: the moviclip gets the position of the body. But if the the bodies are dynamic the movieclip gets the position of the body and sticks to it, even though the body moves on/falls, because of gravity.

I've created this with the help of the kerp.net tutorials, so some things may look familiar to you:

Code:
action = new TagActor(this, new Point(50,20+200*Math.random()), new Point(10,-3));


Code:
public function TagActor(parent:DisplayObjectContainer, position:Point, initSpeed:Point) {
         var tagSkin:Sprite = new tag_html();
         parent.addChild(tagSkin);
         

         var tagHuelle:b2BodyDef = new b2BodyDef();
         tagHuelle.type = b2Body.b2_dynamicBody;
         tagHuelle.position.Set(position.x/Vars.RATIO, position.y/Vars.RATIO);
         
         var tagForm:b2PolygonShape = new b2PolygonShape();
         tagForm.SetAsBox(30/Vars.RATIO, 30/Vars.RATIO);
         
         var tag:b2Body = Vars.world.CreateBody(tagHuelle);
         
         var tagEigenschaften:b2FixtureDef = new b2FixtureDef();
         tagEigenschaften.shape = tagForm;
         tagEigenschaften.density = 4;
         tagEigenschaften.friction = 0;
         tag.CreateFixture(tagEigenschaften);
         
         super(tag, tagSkin);
      }


I call this onEnterFrame
Code:
bodySkin.x = body.GetPosition().x*Vars.RATIO;
bodySkin.y = body.GetPosition().y*Vars.RATIO;
bodySkin.rotation = body.GetAngle()*180/Math.PI;


Example: http://matuzo.at/box2d/index.swf

I would really appreciate some help. If you need more code, or better explanations (I talk/write in english very rarely) just tell me.

thanks in advance
matuzo
I figured it out with the help of one of emanuele feronatos tutorials

if anyone is interested:

Code:
myb2BodyDef.userData = new mc_skin();


Code:
for (var bb:b2Body = myWorld.GetBodyList(); bb; bb = bb.GetNext()) {
   if (bb.GetUserData() is Sprite) {
      bb.GetUserData().x = bb.GetPosition().x * 30;
      bb.GetUserData().y = bb.GetPosition().y * 30;
      bb.GetUserData().rotation = bb.GetAngle() * (180/Math.PI);
   }
}
Congratulations, matuzo!

WoW~ You are on Todd's tutorial, me too! I really like Chap.2 - tons of basics of game design and programming.
We can discuss more questions about it later:)

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