How I can use picture to userData?

I just changed the HelloWorld, to use pictures instead of MovieClip. But the pictures do not move and remain in the upper left corner.

Code:
package
{      
   import flash.display.Sprite;
   import flash.events.Event;
   // Classes used in this example
   import Box2D.Dynamics.*;
   import Box2D.Collision.*;
   import Box2D.Collision.Shapes.*;
   import Box2D.Common.Math.*;
   
   [SWF(backgroundColor="#000000")]

   
   /**
    * ...
    */
   public class Main extends Sprite
   {
      
      [Embed(source="smile.gif")]
      [Bindable]
      public var Smile: Class;      

      public function Main():void
      {
         // Add event for main loop
         addEventListener(Event.ENTER_FRAME, Update, false, 0, true);
                  
         
         // Creat world AABB
         var worldAABB:b2AABB = new b2AABB();
         worldAABB.lowerBound.Set(-100.0, -100.0);
         worldAABB.upperBound.Set(100.0, 100.0);
         
         // Define the gravity vector
         var gravity:b2Vec2 = new b2Vec2(0.0, 10.0);
         
         // Allow bodies to sleep
         var doSleep:Boolean = true;
         
         // Construct a world object
         m_world = new b2World(worldAABB, gravity, doSleep);         
         
         // Vars used to create bodies
         var body:b2Body;
         var bodyDef:b2BodyDef;
         var boxDef:b2PolygonDef;
         var circleDef:b2CircleDef;
         
         
         
         // Add ground body
         bodyDef = new b2BodyDef();
         //bodyDef.position.Set(15, 19);
         bodyDef.position.Set(10, 12);
         //bodyDef.angle = 0.1;
         boxDef = new b2PolygonDef();
         boxDef.SetAsBox(30, 3);
         boxDef.friction = 0.3;
         boxDef.density = 0; // static bodies require zero density
         body = m_world.CreateBody(bodyDef);
         body.CreateShape(boxDef);
         body.SetMassFromShapes();
         
         // Add some objects
         for (var i:int = 1; i < 10; i++){
            bodyDef = new b2BodyDef();
            bodyDef.position.x = Math.random() * 15 + 5;
            bodyDef.position.y = Math.random() * 10;
            var rX:Number = Math.random() + 0.5;
            var rY:Number = Math.random() + 0.5;
            
            // Box
            boxDef = new b2PolygonDef();
            boxDef.SetAsBox(rX, rY);
            boxDef.density = 1.0;
            boxDef.friction = 0.5;
            boxDef.restitution = 0.2;
            bodyDef.userData = new Smile();
            bodyDef.userData.width = rX * 2 * 30;
            bodyDef.userData.height = rY * 2 * 30;
            body = m_world.CreateBody(bodyDef);
            body.CreateShape(boxDef);
            
            body.SetMassFromShapes();
            addChild(bodyDef.userData);
         }
         
      }
      
      public function Update(e:Event):void{
         
         m_world.Step(m_timeStep, m_iterations);
         
         // Go through body list and update sprite positions/rotations
         for (var bb:b2Body = m_world.m_bodyList; bb; bb = bb.m_next){
            if (bb.m_userData is Sprite){
               bb.m_userData.x = bb.GetPosition().x * 30;
               bb.m_userData.y = bb.GetPosition().y * 30;
               bb.m_userData.rotation = bb.GetAngle() * (180/Math.PI);
            }
         }
         
      }
      
      public var m_world:b2World;
      public var m_iterations:int = 10;
      public var m_timeStep:Number = 1.0/30.0;

   }
   
}
Code:
// Go through body list and update sprite positions/rotations
         for (var bb:b2Body = m_world.m_bodyList; bb; bb = bb.m_next){
            if (bb.m_userData is Sprite){
               bb.m_userData.x = bb.GetPosition().x * 30;
               bb.m_userData.y = bb.GetPosition().y * 30;
               bb.m_userData.rotation = bb.GetAngle() * (180/Math.PI);
            }
         }


that specifically looks for Sprites or a subclass of sprites (including MovieClips)
if your "pictures" are a different data type, you may want to change the if statement.

i suppose you also have the option of removing the if-statement if you only use userData for art attached to bodies.


this is "the if statement"
if (bb.m_userData is Sprite){
-if your planning to remove it, don't forget about the closing bracket.
Thanks. I could use pictures. But it's not good idea, because scale of a pictures in the flash it's awful. 🙁

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