         } 
     }
 
-	//----------------------------------
-	//  repeat
-	//----------------------------------
-
-	[Bindable("propertyChange")]
-	[Inspectable(category="General")]
-
-	/**
-	 *  Whether the bitmap is repeated to fill the area. Set to <code>true</code> to cause 
-	 *  the fill to tile outward to the edges of the filled region. 
-	 *  Set to <code>false</code> to end the fill at the edge of the region.
-	 *
-	 *  @default true
-	 */
-	public function get repeat():Boolean 
-	{
-		return _resizeMode == _REPEAT_UINT;
-	}
-	
+    //----------------------------------
+    //  repeat
+    //----------------------------------
+
+    [Bindable("propertyChange")]
+    [Inspectable(category="General")]
+
+    /**
+     *  Whether the bitmap is repeated to fill the area. Set to <code>true</code> to cause 
+     *  the fill to tile outward to the edges of the filled region. 
+     *  Set to <code>false</code> to end the fill at the edge of the region.
+     *
+     *  @default true
+     */
+    public function get repeat():Boolean 
+    {
+        return _resizeMode == _REPEAT_UINT;
+    }
+    
     /**
      *  @private
      */
-	public function set repeat(value:Boolean):void
-	{
-		var oldValue:Boolean = repeat;
-		
-		if (value != oldValue)
-		{
-		    resizeMode = value ? BitmapResizeMode.REPEAT : BitmapResizeMode.NORMAL;  
-			invalidateDisplayList();
-			dispatchPropertyChangeEvent("repeat", oldValue, value);
-		}
-	}
-
-	//----------------------------------
-	//  source
-	//----------------------------------
-
-	[Bindable("propertyChange")]
-	[Inspectable(category="General")]
-
-	/**
-	 *  The source used for the bitmap fill. The fill can render from various graphical 
-	 *  sources, including the following: 
-	 *  <ul>
-	 *   <li>A Bitmap or BitmapData instance.</li>
-	 *   <li>A class representing a subclass of DisplayObject. The BitmapFill instantiates 
-	 *       the class and creates a bitmap rendering of it.</li>
-	 *   <li>An instance of a DisplayObject. The BitmapFill copies it into a Bitmap for filling.</li>
-	 *   <li>The name of a subclass of DisplayObject. The BitmapFill loads the class, instantiates it, 
-	 *       and creates a bitmap rendering of it.</li>
-	 *  </ul>
+    public function set repeat(value:Boolean):void
+    {
+        var oldValue:Boolean = repeat;
+        
+        if (value != oldValue)
+        {
+            resizeMode = value ? BitmapResizeMode.REPEAT : BitmapResizeMode.NORMAL;  
+            invalidateDisplayList();
+            dispatchPropertyChangeEvent("repeat", oldValue, value);
+        }
+    }
+
+    //----------------------------------
+    //  source
+    //----------------------------------
+
+    [Bindable("propertyChange")]
+    [Inspectable(category="General")]
+
+    /**
+     *  The source used for the bitmap fill. The fill can render from various graphical 
+     *  sources, including the following: 
+     *  <ul>
+     *   <li>A Bitmap or BitmapData instance.</li>
+     *   <li>A class representing a subclass of DisplayObject. The BitmapFill instantiates 
+     *       the class and creates a bitmap rendering of it.</li>
+     *   <li>An instance of a DisplayObject. The BitmapFill copies it into a Bitmap for filling.</li>
+     *   <li>The name of a subclass of DisplayObject. The BitmapFill loads the class, instantiates it, 
+     *       and creates a bitmap rendering of it.</li>
+     *  </ul>
      *  
      *  <p>If you use an image file for the source, it can be of type PNG, GIF, or JPG.</p>
      *  

/**
 *  A BitmapGraphic element defines a rectangular region in its parent element's 
 *  coordinate space, filled with bitmap data drawn from a source file.
 */
public class BitmapGraphic extends GraphicElement
{
	include "../core/Version.as";

	//--------------------------------------------------------------------------
	//
	//  Constructor
	//
	//--------------------------------------------------------------------------

	/**
	 *  Constructor. 
	 */
	public function BitmapGraphic()
	{
		super();
		
		_fill = new BitmapFill();
	}
	
	private var _fill:BitmapFill;
	
	//--------------------------------------------------------------------------
	//
	//  Properties
	//
	//--------------------------------------------------------------------------

	//----------------------------------
	//  alwaysNeedsDisplayObject
	//----------------------------------
	
	private var _alwaysNeedsDisplayObject:Boolean = false;
	
	/*
	 *  Set this to true to force the Graphic Element to create an underlying Shape
	 */
	mx_internal function set alwaysNeedsDisplayObject(value:Boolean):void
	{
		if (value != _alwaysNeedsDisplayObject)
		{
			_alwaysNeedsDisplayObject = value;
			notifyElementLayerChanged();
		}
	}
	
	mx_internal function get alwaysNeedsDisplayObject():Boolean
	{
		return _alwaysNeedsDisplayObject;
	}
	
    //----------------------------------
    //  resizeMode
    //----------------------------------
    protected static const _NORMAL_UINT:uint = 0;
    protected static const _REPEAT_UINT:uint = 1;
    protected static const _SCALE_UINT:uint = 2;

    /**
     *  Converts from the <code>String</code> to the <code>uint</code>
     *  representation of the enum values.
     */
    protected static function resizeModeToUINT(value:String):uint
    {

     *  @see flash.display.Bitmap
     *  @see flash.display.BitmapData
     *  @see mx.graphics.BitmapFill
     */
    public function get source():Object
    {
        return _fill.source;
    }
    
    /**
     *  @private
     */
    public function set source(value:Object):void
    {
        var oldValue:Object = _fill.source;
        
        if (value != oldValue)
        {
            var bitmapData:BitmapData;
            var tmpSprite:DisplayObject;
            
            // This code stolen from BitmapFill. The only change is to make the BitmapData transparent.
            if (value is Class)
            {
                var cls:Class = Class(value);
                tmpSprite = new cls();
            }
            else if (value is BitmapData)
            {
                bitmapData = value as BitmapData;
            }
            else if (value is Bitmap)
            {
                bitmapData = value.bitmapData;
            }
            else if (value is DisplayObject)
            {
                tmpSprite = value as DisplayObject;
            }
            else if (value is String)
            {
                var tmpClass:Class = Class(getDefinitionByName(String(value)));
                tmpSprite = new tmpClass();
            }
            else
            {
                return;
            }
            
            if (!bitmapData && tmpSprite)
            {
                bitmapData = new BitmapData(tmpSprite.width, tmpSprite.height, true, 0);
                bitmapData.draw(tmpSprite, new Matrix());
            }       
            
            _fill.source = bitmapData;
            dispatchPropertyChangeEvent("source", oldValue, value);
            invalidateSize();
            invalidateDisplayList();
        }
    }
    
    //----------------------------------
    //  smooth
    //----------------------------------

    private var _smooth:Boolean = false;

    [Inspectable(category="General")]   
    
    /**
     *  @copy flash.display.GraphicsBitmapFill#smooth
     *
     *  @default false
     */
    public function set smooth(value:Boolean):void
    {
        if (value != _smooth)
        {
            _smooth = value;
            invalidateDisplayList();
        }
    }
    
    /**
     *  @private
     */
    public function get  smooth():Boolean
    {
        return _smooth;
    }
    
    //--------------------------------------------------------------------------
    //
    //  IGraphicElement Implementation
    //
    //--------------------------------------------------------------------------
    
    /**
     *  @inheritDoc
     */
    override protected function measure():void
    {
        measuredWidth = source ? source.width : 0;
        measuredHeight = source ? source.height : 0;
    }
    
    /**
     *  @inheritDoc
     */
    override protected function updateDisplayList(unscaledWidth:Number, 
                                                  unscaledHeight:Number):void
    {
        /* if (!displayObject || !(displayObject is Sprite))
            return; */

        if (displayObject is Sprite)
            Sprite(displayObject).graphics.clear();
        else if (displayObject is Shape)
            Shape(displayObject).graphics.clear();

        var g:Graphics = Sprite(drawnDisplayObject).graphics;
        
        g.lineStyle();
        _fill.offsetX = drawX;
        _fill.offsetY = drawY;
        _fill.smooth = smooth;
        _fill.repeat = false;
        _fill.scaleX = 1;
        _fill.scaleY = 1;
        var fillWidth:Number;
        var fillHeight:Number;

        switch(_resizeMode)
        {
