hi,
i have somthing to do with DestroyBody that i'm not sure how to deal with,
its more my lack of AS3 knowledge of Iterators...
here i have a function that is supposed to destroy my bounds when screen is resized,
Code:
public function destroyBounds(event:Event = null):void
{
for (var bb:b2Body = Box2D_PhysicsEngineModel.m_world.m_bodyList; bb; bb = bb.m_next)
{
if ((bb.m_userData.name == "leftBoundMC" || bb.m_userData.name == "rightBoundMC" || bb.m_userData.name =="bottomBoundMC"))
{
_stage.removeChild(bb.m_userData);
bb.m_userData = null;
Box2D_PhysicsEngineModel.m_world.DestroyBody(bb);
}
}
buildBounds();
}
the removing of the SPRITES work fine,
and i null it after removal, but whn i try destroy the body from the engine,
it only removes the first time this iterator is executed.
is because bb is actually the
m_bodyList itself, so i am deleting the list?
how would i code this so that it removes the current element, and logically move the pointer to the next list element (AS3)?
or maybe target the current b2Body the iterator is at?
thanks
Clark