using userData

Hey I saw this in the manual:
GameActor* actor = GameCreateActor();
b2BodyDef bodyDef;
bodyDef.userData = actor;
actor->body = box2Dworld->CreateDynamicBody(&bodyDef);

Is this possible in AS3 in any way? I know pointers are necissarily supported...I was wondering because I would like to have a function in my "actor" class
that when called will destroy its related body from the world...how can I do this?

Inside of my class initialization here is basically what I did:

initialize(){
//code...
bodyDef.userData = this;
world.createBody(bodyDef);
//code...
}

and I have :
destroy(){
//code...

//need to destroy the body here, how?

//code...

Hopefully that made sense.
Thanks!
Code:
var body:b2Body;
body = world.createBody(bodyDef);


Of course "body" would be a property of the Actor object. I'm actually using arrays to hold the bodies in my Actor class though, because you can have actors that would need more than one (like a ragdoll). This way you keep a reference to the body so you can destroy it/them later.
Whoa, an NG user on this forum? I might think about your co-op thread. :p

In almost any case you'll want to create a class to handle the activity of one or more bodies. Then just keep a reference to those bodies in the class. Myself I only use userData to reference the associated graphics objects so I don't have to sync them from their actors (although the actors do reference the display objects in case they need to be removed and such). Then use those references to remove the bodies and display objects.
Thanks for the answers! Damn, such a simple solution (as always) hehe.

Hrmm, unrelated problem: I cannot seem to get my body to "simulate" in other words it just sits there and doesn't fall down from gravity or anything.

Not sure what the problem is...I made sure to set the density. I can't really link the code because it's in a few classes. If anyone has some ideas on how to debug to find the problem that would be cool...umm or I can send you the files as a zip or something if you message me on MSN: colby (at) cheezeworld [dot] com

*bangs head on wall*

Almost done with the first alpha release of my framework! Just gotta figure this out...

*edit* when I trace _body.m_mass after world.createBody(bodyDef); I get NaN. Is this the problem? If so how do I fix it?
Yes that's a problem. How are you creating the body?
Nevermind fixed that, I was giving it data it a number I hadn't initialized yet.

New problem though...I am unable to destroy bodies.

I have a reference to my body now in my charater _body and on it's destroy I do
world.DestroyBody(_body);

This however does not destroy the body...

Anybody have an idea as to what is wrong?

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