    */ 
     public function ErrorField(downloadProgressBar:DownloadProgressBar)
     {
-    	super();
+        super();
         this.downloadProgressBar = downloadProgressBar;
     }
     

 */
public class DownloadProgressBar extends Sprite implements IPreloaderDisplay
{
	include "../core/Version.as";
	
	//--------------------------------------------------------------------------
	//
	//  Constructor
	//
	//--------------------------------------------------------------------------
	
	/**
	 *  Constructor.
	 *  
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 3
	 */
	public function DownloadProgressBar() 
	{
		super();
	}

	//--------------------------------------------------------------------------
	//
	//  Variables
	//
	//--------------------------------------------------------------------------
	
	/**
	 *  The minimum number of milliseconds
	 *  that the display should appear visible.
	 *  If the downloading and initialization of the application
	 *  takes less time than this value, then Flex pauses for this amount
	 *  of time before dispatching the <code>complete</code> event.
	 *
	 *  @default 0
	 *  
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 3
	 */
	protected var MINIMUM_DISPLAY_TIME:uint = 0;
	
	/**
	 *  The percentage of the progress bar that the downloading phase
	 *  fills when the SWF file is fully downloaded.
	 *  The rest of the progress bar is filled during the initializing phase.
	 *  This should be a value from 0 to 100. 
	 *
	 *  @default 60
	 *  
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 3
	 */
	protected var DOWNLOAD_PERCENTAGE:uint = 60;

	/**
	 *  @private
	 */
	private var _showProgressBar:Boolean = true;
		
	/**
	 *  @private
	 *  Cached Rectangle returned by the labelRect getter.
	 */
	private var _labelRect:Rectangle = labelRect;

	/**
	 *  @private
	 *  Cached Rectangle returned by the percentRect getter.
	 */
	private var _percentRect:Rectangle = percentRect;

	/**
	 *  @private
	 *  Cached RoundedRectangle returned by the borderRect getter.
	 */
	private var _borderRect:RoundedRectangle = borderRect;

	/**
	 *  @private
	 *  Cached RoundedRectangle returned by the barFrameRect getter.
	 */
	private var _barFrameRect:RoundedRectangle = barFrameRect;

	/**
	 *  @private
	 *  Cached RoundedRectangle returned by the barRect getter.
	 */
	private var _barRect:RoundedRectangle = barRect; 
	
	/**
	 *  @private
	 */
	private var _xOffset:Number = 20;
	
	/**
	 *  @private
	 */
	private var _yOffset:Number = 20;
	
	/**
	 *  @private
	 */
	private var	_maximum:Number = 0;
	
	/**
	 *  @private
	 */
	private var	_value:Number = 0;
	
	/**
	 *  @private
	 */
	private var _barSprite:Sprite;

	/**
	 *  @private
	 */
	private var _barFrameSprite:Sprite;
	
	/**
	 *  @private
	 */
	private var _labelObj:TextField;

	/**
	 *  @private
	 */
	private var _percentObj:TextField;

	/**
	 *  @private
	 */
	private var _startTime:int;

	/**
	 *  @private
	 */
	private var _displayTime:int;
		
	/**
	 *  @private
	 */
	private var _startedLoading:Boolean = false;

	/**
	 *  @private
	 */
	private var _startedInit:Boolean = false;

	/**
	 *  @private
	 */
	private var _showingDisplay:Boolean = false;
	
	/**
	 *  @private
	 */
	private var _displayStartCount:uint = 0; 

	/**
	 *  @private
	 */
	private var _initProgressCount:uint = 0;

	/**
	 *  The total number of validation events you expect to get
	 *  in the initializing phase.  This should be an integer
	 *  greater or equal to 4 (and note that if it is greater than 4
	 *  you might have an inefficiency in your initialization code)
	 *
	 *  @default 6
	 *  
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 4
	 */
	protected var initProgressTotal:uint = 6;

	//--------------------------------------------------------------------------
	//
	//  Overridden properties
	//
	//--------------------------------------------------------------------------

	//----------------------------------
	//  visible
	//----------------------------------
	
	/**
	 *  @private
	 *  Storage for the visible property.
	 */
	private var _visible:Boolean = false;

	/**
	 *  Specifies whether the download progress bar is visible.
	 *
	 *  <p>When the Preloader control determines that the progress bar should be displayed, 
	 *  it sets this value to <code>true</code>. When the Preloader control determines that
	 *  the progress bar should be hidden, it sets the value to <code>false</code>.</p>
	 *
	 *  <p>A subclass of the DownloadProgressBar class should never modify this property. 
	 *  Instead, you can override the setter method to recognize when 
	 *  the Preloader control modifies it, and perform any necessary actions. </p>
	 *
	 *  @default false 
	 *  
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 3
	 */
	override public function get visible():Boolean
	{
		return _visible;
	}

	/**
	 *  @private
	 */
	override public function set visible(value:Boolean):void
	{
		if (!_visible && value) 
			show();
		
		else if (_visible && !value ) 
			hide();
		
		_visible = value;
	}
	
	//--------------------------------------------------------------------------
	//
	//  Properties: IPreloaderDisplay
	//
	//--------------------------------------------------------------------------
	
	//----------------------------------
	//  backgroundAlpha
	//----------------------------------

	/**
	 *  @private
	 *  Storage for the backgroundAlpha property.
	 */
	private var _backgroundAlpha:Number = 1;

	/**
     *  Alpha level of the SWF file or image defined by 
     *  the <code>backgroundImage</code> property, or the color defined by 
	 *  the <code>backgroundColor</code> property. 
	 *  Valid values range from 0 to 1.0.	 
	 *
	 *  <p>You can specify either a <code>backgroundColor</code> 
	 *  or a <code>backgroundImage</code>, but not both.</p>
	 *
	 *  @default 1.0
	 *
	 *  
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 3
	 */
	public function get backgroundAlpha():Number
	{
		if (!isNaN(_backgroundAlpha))
			return _backgroundAlpha;
		else
			return 1;
	}
	
	/**
	 *  @private
	 */
	public function set backgroundAlpha(value:Number):void
	{
		_backgroundAlpha = value;
	}
	
	//----------------------------------
	//  backgroundColor
	//----------------------------------

	/**
	 *  @private
	 *  Storage for the backgroundColor property.
	 */
	private var _backgroundColor:uint;

	/**
     *  Background color of a download progress bar.
     *  You can have either a <code>backgroundColor</code> or a
     *  <code>backgroundImage</code>, but not both.
	 *  
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 3
	 */	
	public function get backgroundColor():uint
	{
		return _backgroundColor;
	}

	/**
	 *  @private
	 */
	public function set backgroundColor(value:uint):void
	{
		_backgroundColor = value;
	}
	
	//----------------------------------
	//  backgroundImage
	//----------------------------------

	/**
	 *  @private
	 *  Storage for the backgroundImage property.
	 */
	private var _backgroundImage:Object;

	/**
	 *  The background image of the application,
	 *  which is passed in by the preloader.
	 *  You can specify either a <code>backgroundColor</code> 
	 *  or a <code>backgroundImage</code>, but not both.
	 *
	 *  <p>A value of null means "not set". 
	 *  If this style and the <code>backgroundColor</code> style are undefined, 
	 *  the component has a transparent background.</p>
	 *
	 *  <p>The preloader does not display embedded images. 
	 *  You can only use images loaded at runtime.</p>
	 *
	 *  @default null
	 *  
	 *  @langversion 3.0
	 *  @playerversion Flash 9
	 *  @playerversion AIR 1.1
	 *  @productversion Flex 3
	 */
	public function get backgroundImage():Object
	{
		return _backgroundImage;
	}
	
	/**
	 *  @private
	 */
	public function set backgroundImage(value:Object):void
	{
		_backgroundImage = value;
	}
	
	//----------------------------------
	//  backgroundSize
	//----------------------------------

	/**
	 *  @private
	 *  Storage for the backgroundSize property.
	 */
	private var _backgroundSize:String = "";

	/**
     *  Scales the image specified by <code>backgroundImage</code>
     *  to different percentage sizes.
     *  A value of <code>"100%"</code> stretches the image

        textField.autoSize = TextFieldAutoSize.LEFT;
        textField.multiline = true;
        textField.wordWrap = true;
        textField.background = true;
        textField.defaultTextFormat = labelFormat;
        textField.text = errorText;

        textField.width = Math.max(MIN_WIDTH_INCHES * Capabilities.screenDPI, screenWidth - (TEXT_MARGIN_PX * 2));
