bitmapData from embedded image?

Hey everyone,

How would you fill a bitmapData with an embedded image?

This is what I have so far. I’ve read the language reference, but I have no clue as to where to go from here.

// Embed images
        [Embed(source="texture.PNG")]
        private var Texture:Class;

        private function createBox(x:Number, y:Number, w:Number, h:Number, friction:Number, restitution:Number, static:Boolean, mode:uint, fill:Object):void {
            // Modes: 0 - solid fill, 1 - gradient fill, 2 - bitmap fill
            trace("function:createBox");
            
            bodyDef = new b2BodyDef();
            bodyDef.position.Set(x, y);
            boxDef = new b2PolygonDef();
            var boxCenter:b2Vec2 = new b2Vec2(w, h);
            boxDef.SetAsOrientedBox(w, h, boxCenter);
            boxDef.friction = friction;
            boxDef.restitution = restitution;
            if (static) {boxDef.density = 0;} else {boxDef.density = 1.0;}
            bodyDef.userData = new Shape();
            if (mode == 0) {
                bodyDef.userData.graphics.beginFill(fill);
                bodyDef.userData.graphics.lineStyle(0, 0x000000);
                bodyDef.userData.graphics.drawRect(0, 0, w, h);
                bodyDef.userData.graphics.endFill();
            } else if (mode == 1) {
                
            } else if (mode == 2) { /// THIS IS WHERE THE PROBLEM STARTS ///
                var bitmapdata:BitmapData = new BitmapData(5, 5, false);
                bitmapdata.draw(fill); //bitmapdata.draw(Texture); doesn't work either
                bodyDef.userData.graphics.beginBitmapFill(bitmapdata);
                bodyDef.userData.graphics.drawRect(0, 0, w, h);
                bodyDef.userData.graphics.endFill();
            }
            bodyDef.userData.width = w * 2 * 30; 
            bodyDef.userData.height = h * 2 * 30;
            addChild(bodyDef.userData);
            body = m_world.CreateBody(bodyDef);
            body.CreateShape(boxDef);
            body.SetMassFromShapes();
        }

It gives me an error that I cannot draw Classes or Objects into bitmapData, but I don’t know what else I could do…

Thanks for reading!