Simple spawns (from a beginner)

Hey, I am relatively new to physics engines (and AS3 for that matter) but I was wondering if anyone would be able to help me with a problem that I have been having.

Basically, I am looking to spawn a few objects onto the screen (look at them as basic balls), at random positions accross the top of the screen. I then want the physics to take effect on them and for them to fall/collide with what I have already underneath.

I tried to do this with basic spawns, but it doesnt spawn them into the physics world and I have been unable to find anywhere that says how to do it. I have seen in the demo (on the stacked boxes one) that you could also set it up for me to click to spawn things in, but I have been unable to extract what I need from the demo due to being a beginner 🙂

Any help would be greatly appreciated!
If you have a WCK world, then any display objects you add to it (via addChild) that extend BodyShape (or any of its subclasses, Box, Circle, Etc.) should automatically interact with the physics system. that's how the demo you referenced works.
This might sound strange but my first suggestion: if you are stuck, get familiar with AS3 first. It took me a while to switch from AS1 because there are many "custom" features that can make you go like 🙄

In general, if you can also post relevant parts of your code, others might have a better idea how much help you need (i.e. what are you already familiar with).

Yes, I was looking for the exact same thing: creating most things from code (instead of drag and drop) and it is possible. YAY! 😀

First, make sure you do have the various libraries mentioned in the basic tutorials set up properly. If you are using one the tutorials, then that should be fine.

As mayo mentioned, you need to use addChild. If you already have 'world' on stage, then you can use: world.addChild(myBall); (might need to either give it the instance name 'world' or even create the world from code alltogether).

There are few helpful links here: https://github.com/jesses/wck/wiki/

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