AS3 2.1 Port (Alchemy), WCK Update and Kinematic Demos

Adding the full wck folder to my source path seems to do the trick. I can import the packages now. I don't like to have all the wck stuff in my project though - It's great stuff and all that, but I just want to play around with pure Box2D. You really should do a clean release of Box2D without wck.

I don't use the "fl.*" packages, but I think they are part of the Flash authoring environment and hence not open source. Not sure though.
The FL package is only available to those with Flash. It is not available in the flex SDK but you can copy over the fl package from your Flash Directory.

C:\Program Files (x86)\Adobe\Adobe Flash CS4\Common\Configuration\ActionScript 3.0\projects\Flash\src\fl

On the other hand you could use open source Tweener AS3 or Greensock Tweener both of which are much better than the native tween package but its really not my place to say.
I'm trying to make the gravity objects to affect in a limited area.
i mean like the closer to the gravity the stronger it pulls and to have a limit of effect.
I'm breaking my head on how to make it?
thanks
mayobutter wrote:
You probably don't have the latest update to Flash CS4. It's free and fixes a bug with large projects.


Well, I'm using the trial version of CS4, so I don't think that's an option for me.

But, it's not a problem; the demo set that comes with Boris's port seems to be completely independent of the Flash IDE, so I'll just use that, and build from there.
ChronoDK: The Box2DAS is completely independent. Just copy it and drop it into your source folder if you don't want anything else. Or check out just that folder from github.

arkzai: BorisTheBrave released a "real" gravity controller at some point. It would be pretty easy to adapt.

milo: The "TestBed" folder is also completely independent of Flash and should compile just fine - it demos just the core stuff.

evilsatan: You could also use the "doOutsideTimeStep()" function on the world object. It'll delay your function call until the world is unlocked. Use it like so:

Code:
world.doOutsideTimeStep(function():void { /* joint creation code */ });
Hi,

I noticed a rather nasty bug tonight while profiling my game in Flex Builder, DestroyBody isn't cleaning up after itself, everything is getting left in memory.

To make sure it wasn't my code i profiled the Box2DAS testbed with the same results. I deleted bodies on the decomposition demo and the b2Body (and of course all the things that go with it like fixtures and filters and b2Vec2's etc) instances never decrease.

One more test i did was to create a demo that creates and deletes bodies over and over again, and the memory and instances just grow and grow.

Also the following code does not work as it should because destroy() is setting m_next to null, hence only the first body is destroyed and the for loop ends.

Code:
for (body = GetBodyList(); body != null; body = body.GetNext())
{
   DestroyBody(body);
}


I hope this can be fixed as im loving this port, it's been perfect for me in every other way.

Thank you for your time and hard work.
Do you have any indication whether the memory leak is happening in C++ / Alchemy or if its just not getting garbage collected in AS3? The C++ code looks pretty tight, but I suppose its possible AS3 body references get left somewhere.

If you want to use that loop structure, just remove these lines from b2Body::Destroy():

Code:
m_next = null;
m_prev = null;


I agree that it may be handy to loop in that manner.
I'm not sure what the Flex Profiler actualy takes into account when it comes to Alchemy, but it probably ignores the c++ side of things which means some AS3 reference to a body isn't being removed when destroy is called.

I did another profile of the test bed, this time i just switched between the different demo's and the same problem happens, nothing is getting removed properly and the cumulative instances are the same as the instances.

I don't know if this will be helpfull but here is a screenshot of the profiler while profiling a demo that creates and destroys body's a few times every second: http://www.peslauncher.com/test3/capture.jpg

If you look at that you can see the current instances = cumulative instances, but the current instances should be leveling out at arround 20.
This is the demos running in the latest Box2D version of SVN (r58):

http://www.sideroller.com/wck/demo58.swf (resize your browser to get a better frame rate)

Some of the demos completely break down in this version, especially the pinball demo and the kinematic line arcs.

This is really disappointing. I was originally planning on keeping the Alchemy port up to date with SVN, but this version just feels too wrong.
I agree, it's a shame that the new version is causing these problems. I definitely support your sticking to the old version if that's what you decide to do for the time being.

Btw, quick bug-fix: the 'max' method on V2 is 'min'ing instead of 'max'ing the coordinates.

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