WCK tutorial, can't make it work ;/

Hi

I would like to excuse myself for having so little action script programing experience. I'm trying to learn how to use WCK in any flash using simpliest tutorial possible: http://wiki.github.com/jesses/wck/ and still fail 🙁

I'm using Flash CS5 trial version from adobe.com and maybe that's an issue, but i'm unable to complete the tutorial due to:

Quote:
Creating our World: Creating a Physics-Affected Box:
* Check Export for ActionScript
* Change Base class to shapes.Box
* Check definition found for the shapes.Box class (Success!)

I don't understand this one. There is no checkbox to check, just plain textfield? Should I click this little green check called 'Validate base class definition'?
If yes answer for it is: The definition for this class has been found at d:\flash\wck-lib\shapes\Box.as

Quote:
Creating our World: Creating the World Instance
* Check Export for ActionScript
* Change Base class to wck.World
* Check definition found for the shapes.Box class (Success!)

Again the same with more confusion here. Again green check 'Validate base class definition'? It says wck.World here (I changed that line earlier) and it founds that at d:\flash\wck-lib\wck\World.as

Creating our World: Creating 4 Walls and a Box
Quote:
* Open Component Inspector (Shift-F7)
* Change ‘Type’ to ‘Static’ (right down the bottom of the list)

It's impossible, since Component inspector is empty. There are no properties, nor bindings, nor schema for myRectangle.

Quote:
* Copy your floor to create walls and a ceiling now, doesn’t matter if they overlap.
* Drag a new ‘MyRectangle’ from the Library to the stage

Just to be on a safe side: myRectangle (non static) should be inside myWorld object?

After completing tutorial all i got is square in a frame which isn't dragable or anything 😛
I'm sure i just miss some detail, but i've never worked with any physics engine before.

I'm attaching a file, which might help
Ty in advance for any help and sory for being lame 🙁
I think CS5 is not supported yet, see other threads.
The latest commit is CS5 compatible. Try right clicking your box symbol in your library and selecting "Component Definition" then type in "wck.BodyShape" then hit OK. The symbol for the box in the library should shange to a component symbol. I was able to get your project working, although I had to relink the Box2D.swc file and the wck-lib folder.
Ah cool, sorry for the misinformation 🙂
Ist it worth switching to CS5 ?
Frnk wrote:
Ah cool, sorry for the misinformation 🙂
Ist it worth switching to CS5 ?


No.
Thanks i've made it work 😛

I've run into few other problems, and just a quick question, will rolling back to cs4 help me out?

1. I have some problems with basic WCK definitions and I'm affraid it might be connected to CS5 when I use:
Code:
var pos:b2Vec2=new b2Vec2(-120.0+ca*110.0, -130.0+sa*110.0);     // where -120, -130 its cannon base pos, 110 it's height, ca - cos angle, sa sine angle
I'm getting error:
Scene 1, Layer 'AS', Frame 1, Line 113 1137: Incorrect number of arguments. Expected no more than 1.

When I changed the declaration to:
Code:
var pos:b2Vec2=new b2Vec2();
pos.x=-120.0+ca*110.0;
pos.y=-130.0+sa*110.0;
Got:
Scene 1, Layer 'AS', Frame 1, Line 113 1136: Incorrect number of arguments. Expected 1.

I've checked both wck-lib path and box2d.swc path and they're correct as far as I know. I've looked up the declaration of b2Vec2 class and constructor takes 2 arguments with defaults 0, so it should either take 2 arguments or 0 (in my opinion), but why he only accepts one? It finally compiles with:
Code:
var pos:b2Vec2=new b2Vec2(1);
pos.x=-120.0+ca*110.0;
pos.y=-130.0+sa*110.0;
But I consider it a dirty solution.

2. I need to insert an object from library into specific location onto world and add some base impulse to it (firing cannon).
I've run into several tutorials made for flex in which you create your own rectangle and add it to scene. But I already have my object in Library, and just need to insert it to the scene. And i'm not sure how to do that.

Alternatively I tried to move one object over and over again (one cannon ball shoot, after another shoot it moves back to cannon with 0 speed and everything starts over, but I'm unable to move the 'Dynamic' object using only ActionScript. So I figured I needed to change it's type to 'Animated' (which can be freely moved by ActionScript), but then the object is no longer animated by WCK, so I figured i need to switch it's type back to 'Dynamic'. Yet after this modification object still isn't animated by WCK.

But still i'm committed (and forced 😛) to complete my project 😛 Which hopefully will be some lame game, but in the meantime I will learn how to write better programs in future ;P
I'm not sure if it helps, but I've compresed my project and attached it here. In first frame at very bottom is event listener function, which (after releasing space) should fire cannon ball in world 10 frames later (under label 'game')
DO NOT INSTANTIATE b2Vec2. b2Vec2 represents a C++ vector. Use V2. V2 is an AS3 vector. This is an awkward part of the alchemy port with no solution. If you instantiate a b2Vec2 and manipulate it, you're basically writing over random memory.
O.o, but i've found b2Vec2 in almost every box2d flash tutorial on the net.

But thank you, with V2 it works correctly ;P Which brings me to the question about SetXForm which I found was the appropriate way to move objects inside world. But when I use it as I think it should i got:
Code:
   var pos:V2=new V2(-120.0+ca*110.0, -130.0+sa*110.0);
      game.cannonball.SetXForm(pos,0);

Where game is world instance, and cannonball is shape.circle instance (dynamic):
TypeError: Error #1006: SetXForm is not a function.
at wck::WCK/key_released()

I googled it: No results found for "SetXForm is not a function.". I think I must have messed something up with setting up enviroment for wck, since i'm sure it's a proper function 😛 Same response for changing it to SetTransform:

TypeError: Error #1006: SetTransform is not a function.
at wck::WCK/key_released()
"almost every box2d flash tutorial on the net." is not about alchemy/wck.
alchemy/wck is are separate ports from Box2DFlash

the V2 class is alchemy/wck specific, for regular Box2DFlash users, b2Vec2 is the correct class.

I assume the restriction for V2 to have a different name is a name-space conflict that must somehow overlap the C++ used by alchemy.
SetXForm is probably a function of the b2Body, but not of the BodyShape.

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