AS3 2.1 Port (Alchemy), b2Vect2 signature?

Hello,

I'm trying to use WCK without Flash IDE. I want to to test how much faster it is compared to Box2DFlash 2.1.
I've coded a test class for Box2DFlash 2.1, and now I'm trying to use it with the WCK library instead.

I found that the b2Vect2 class in Box2DAS (the WCK interface) has a different signature than the original b2Vect2 class.

Box2DFlash
public function b2Vec2(x_:Number=0, y_:Number=0)

WCK
public function b2Vec2(p:int)

Any hints?

Thanks!
b2Vec2: Do NOT create these, ever. Instead use the V2 class. b2Vec2 references a b2Vec2 in Alchemy memory. The one constructor parameter is a pointer to where that b2Vec2 memory location. The V2 class is for AS3 side vector operations. You can sync them like so:

Code:
var myV2:V2 = new V2(10, 10);
someBodyDef.position.v2 = myV2;


You can also do:

Code:
someBodyDef.position.x = 10;
someBodyDef.position.y = 10;


And if you want to convert a b2Vec2 into a V2 to do fancy vector operations on it:

Code:
var myV2:V2 = someBody.m_linearVelocity.v2;
myV2.normalize(10);
someBody.m_linearVelocity.v2 = myV2;



I've considered merging the two classes but that implementation turned out to be just as awkward.
Thank you! That worked.

Now, I must be doing something wrong, because I'm getting a runtime error with a simple test:

Code:
TypeError: Error #1006: value is not a function.
   at cmodule.Box2D::FSM__Z20b2Body_CreateFixturePvP8_AS3_Val/work()
   at <anonymous>()
   at <anonymous>()
   at Box2DAS.Dynamics::b2Fixture()[D:\Tests\wck\lib\wck-c41c941\Box2DAS\Dynamics\b2Fixture.as:25]
   at Box2DAS.Dynamics::b2Body/CreateFixture()[D:\Tests\wck\lib\wck-c41c941\Box2DAS\Dynamics\b2Body.as:102]
   at Test/init()[D:\Tests\wck\src\Test.as:51]
   at Test()[D:\Tests\wck\src\Test.as:20]


Test.as:51 is the last line in my code below:

Code:
// Create World
b2Base.initialize();
var gravity:V2 = new V2(0, 10);         
var world:b2World = new b2World( gravity, true);

// Create Body
var b_def:b2BodyDef = new b2BodyDef();
b_def.type = b2Body.b2_dynamicBody;
b_def.position.x = 12 + Math.random();
b_def.position.y = 0;
var shape:b2CircleShape = new b2CircleShape( 1 );
var fixdef:b2FixtureDef = new b2FixtureDef();
fixdef.shape = shape;
fixdef.density = 1;
fixdef.friction = 0.1;
fixdef.restitution = .5;

_body = world.CreateBody( b_def );
_body.CreateFixture( fixdef ); //   <---- line 51


Any ideas?
Code:
var shape:b2CircleShape = new b2CircleShape( 1 );

Without running it, I'm 99% sure this is your problematic line. Do not pass 1 as the parameter. That creates a circle shape that points to the memory address 1, which is most very likely not the memory address of a circle shape. If you omit that parameter, it'll go ahead and create a new circle shape somewhere in alchemy memory.

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