One more Beginner Question

I have read through most of the manual and it did not have what I was searching for so hopefully it's okay to ask.

Lets say in Flash I created a button with the drawing tools and I want it to become affected by physics. How do I do this?
just let it's position and rotations match a body with a shape thats the same shape as your button,
Let your button be the body's userData OR use GetPosition on the body every frame.
Ah! I found out how to add my own "sprites" to a primitive. In the Hello World scene I found;
Code:
bodyDef.userData = new PhysCircle();

So would I just convert the button's shape to a Movie Clip symbol, call it something like "Home" and change the code to:

Code:
bodyDef.userData = new Home();
?

Thanks Yager.
yea pretty much
In regards to this question I am finding some problems.

I recieve this error "1151: A conflict exists with definition body in namespace internal" with this code
Code:
var body:b2Body = myWorld.CreateBody(bodyDef);


Here is the rest of my code. "m_sprite" is the name of a Movie Clip object I am trying apply physics to.
Code:
import Box2D.Dynamics.*; // physics
import Box2D.Collision.*; // bounding box
import Box2D.Collision.Shapes.*; // define shapes
import Box2D.Common.Math.*; // for vector
import flash.display.*; // sprite class
   
var worldBox:b2AABB = new b2AABB();
var body:m_sprite;

worldBox.lowerBound.Set(-100,-100) // 1m = 30pixels
worldBox.upperBound.Set(50,50);

bodyDef.userData = new m_sprite();

// gravity
var gravity:b2Vec2 = new b2Vec2(0, 10) // 300 pixels / per second sqaured

var bSleep:Boolean = true;

var myWorld:b2World = new b2World(worldBox, gravity, bSleep);

// Box
var boxDef:b2PolygonDef = new b2PolygonDef();
boxDef.SetAsBox(3,1); // 1 meter = 30 pixels, width 90, height 30
boxDef.friction = 0.3 // between 0 and 1
boxDef.density = 0.5;
var bodyDef:b2BodyDef = new m_sprite();
bodyDef.userData = new Sprite();
bodyDef.userData.width = 90;
bodyDef.userData.height = 30;
bodyDef.position.Set(13, 10) // x = 165, y = 300

addChild(bodyDef.userData);
      
var body:b2Body = myWorld.CreateBody(bodyDef);
body.CreateShape(boxDef);
body.SetMassFromShapes();

// debug draw
var dbgDraw:b2DebugDraw = new b2DebugDraw();
dbgDraw.m_sprite = new Sprite();
addChild(dbgDraw.m_sprite);
dbgDraw.m_drawScale = 30.0;
dbgDraw.m_fillAlpha - 0.3;
dbgDraw.m_lineThickness = 1.0;
dbgDraw.m_drawFlags = b2DebugDraw.e_shapeBit;


myWorld.SetDebugDraw(dbgDraw);

var m_timeStep:Number = 1.0 / 24.0; // (1.0) steps per frame
var m_iterations:int = 10;

addEventListener(Event.ENTER_FRAME, Update, false, 0, true);

function Update(e:Event):void{
   myWorld.Step(m_timeStep, m_iterations);

}


Could you possibly run down a little sample code explaining basically how you would add a Movie Clip object too?
You've declared body twice: once as a Sprite, and once as a b2Body. "namespace internal" means in the unnamed "internal" namespace each function creates for itself, while "conflict" is telling you that you have two things fighting over precedence.
BorisTheBrave wrote:
You've declared body twice: once as a Sprite, and once as a b2Body. "namespace internal" means in the unnamed "internal" namespace each function creates for itself, while "conflict" is telling you that you have two things fighting over precedence.


I know that this is horribly silly but could you please show me how to fix the code? I have a few days left before my assignment is due and the more time I waste trying to get code working, it could be spent somewhere else.
I dread to think what level you are at that you have assignments that expect you to be able use Box2D, but don't expect you to able to deal with these sort of compilation errors, but I suppose that's your problem, not mine 😐
You just need delete the line "var body:m_sprite;", which you are not even using.
Well, the Box2D part was my own idea. My task is too create a website in Flash with a minimum of 3 pages/scenes. One page as to be a game or interactive sequence so I thought I would implement Box2D physics into all the buttons and I will also create a basic sandbox. It is only a year 9 assignment.

I have removed that line. But the thing is I have no idea how I get my own movieclips physical. I have looked through the HelloWorld script countless times. I really need to push on some progress. Can anyone give me some tips on how to get custom bodies into Box2D?
Have you ticked "export for Actionscript" for m_sprite?

In your .fla file:
1. Right click on it in the library and select Linkage.
2. Tick "Export for Actionscript".
3. Type "m_sprite" where it says "Class:"


Then try this for your box code:

Code:
// Box
var boxDef:b2PolygonDef = new b2PolygonDef();
boxDef.SetAsBox(3,1); // 1 meter = 30 pixels, width 90, height 30
boxDef.friction = 0.3 // between 0 and 1
boxDef.density = 0.5;

var bodyDef.userData = new m_sprite();
bodyDef.userData.width = 90;
bodyDef.userData.height = 30;
bodyDef.position.Set(13, 10) // x = 165, y = 300

addChild(bodyDef.userData);
      
var body:b2Body = myWorld.CreateBody(bodyDef);
body.CreateShape(boxDef);
body.SetMassFromShapes();

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