HelloWorld

Discuss issues specific to the Flash/AS3 port of Box2D
sketchbookgames
Posts: 564
Joined: Tue Feb 24, 2009 4:10 pm
Location: Michigan
Contact:

HelloWorld

Postby sketchbookgames » Sun Jan 29, 2012 12:21 pm

HelloWorld.fla should run w/o modification, is there currently a bug in the code?

currently i get the following error.
Location: ...Source\Box2D\Dynamics\b2World.as, Line 871
Description: 1046: Type was not found or was not a compile-time constant: b2Fixture.

line 871 is:
public function RayCastAll(point1:b2Vec2, point2:b2Vec2):Vector.<b2Fixture>

however when i get past this error i see the floor, boxes and circles, and nothing is moving.
I've checked that update is being called.

it's been a little while since I've used a non WCK version of Box2d... i'm afraid I'm a little rusty.
just trying to get HelloWorld.fla working.

edit: it's worth noting which version i am using.
using the latest version from:
http://sourceforge.net/projects/box2dflash/files/box2dflash/Box2DFlashAS3_2.1a/Box2DFlashAS3%202.1a.zip/download

jayther
Posts: 266
Joined: Sun Oct 25, 2009 3:28 am
Contact:

Re: HelloWorld

Postby jayther » Mon Jan 30, 2012 2:05 am

I've never actually run HelloWorld.fla before; I've only ever run PhysTest.fla, since that's what the read me says to run.

Upon running HelloWorld.fla, I got the same "Type was not found..." error, and this was because the .fla is set to run in Flash Player 9. There's no Vector class before Flash Player 10 (and the line it gave an error is a function that returns a Vector of b2Fixtures), so the problem was in the publish settings that went with the .fla file (in case you didn't already know, because you got past that error). This problem is also in PhysTest.fla. There's a Box2D AS3 for Flash Player 9 in case you wanted to work with Arrays rather than Vectors.

But the bug in the code causing the simulation to show a bunch of frozen circles and boxes is the lack of assigning bodyDef.type (the body type (static, kinematic, or dynamic)) with b2Body.b2_dynamicBody in the "for" loop to create the test circles and boxes. The default value in b2BodyDef.type is b2_staticBody, so the HelloWorld simulation actually shows a bunch of static bodies. Adding a line to set bodyDef.type to dynamic would solve this problem and have a working simulation.

sketchbookgames
Posts: 564
Joined: Tue Feb 24, 2009 4:10 pm
Location: Michigan
Contact:

Re: HelloWorld

Postby sketchbookgames » Mon Jan 30, 2012 7:15 pm

many thanks jayther.
for your clear and accurate answer.

jayther
Posts: 266
Joined: Sun Oct 25, 2009 3:28 am
Contact:

Re: HelloWorld

Postby jayther » Mon Jan 30, 2012 9:57 pm

No problem. -]

Cardioth
Posts: 1
Joined: Wed Nov 25, 2015 11:03 pm

Re: HelloWorld

Postby Cardioth » Wed Nov 25, 2015 11:07 pm

bodyDef.type = 2;

will make it dynamic, by the way...


Return to “Flash”



Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests