// Copyright 2007. Adobe Systems Incorporated. All Rights Reserved.
package fl.controls {
import fl.controls.progressBarClasses.IndeterminateBar;
import fl.controls.student_ar_fl_controls_ProgressBarDirection;
import fl.controls.student_ar_fl_controls_ProgressBarMode;
import fl.core.InvalidationType;
import fl.core.UIComponent;
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.ProgressEvent;
//--------------------------------------
// Events
//--------------------------------------
/**
* Dispatched when the load operation completes.
*
* @eventType flash.events.Event.COMPLETE
*
* @includeExample examples/student_ar_fl_controls_ProgressBar.complete.1.as -noswf
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Event("complete", type="flash.events.Event")]
/**
* Dispatched as content loads in event mode or polled mode.
*
* @eventType flash.events.ProgressEvent.PROGRESS
*
* @includeExample examples/student_ar_fl_controls_ProgressBar.complete.1.as -noswf
*
* @see student_ar_fl_controls_ProgressBarMode#EVENT student_ar_fl_controls_ProgressBarMode.EVENT
* @see student_ar_fl_controls_ProgressBarMode#POLLED student_ar_fl_controls_ProgressBarMode.POLLED
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Event("progress", type="flash.events.ProgressEvent")]
//--------------------------------------
// Styles
//--------------------------------------
/**
* Name of the class to use as the default icon. Setting any other icon
* style overrides this setting.
*
* @default null
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="icon", type="Class")]
/**
* Name of the class to use as the progress indicator track.
*
* @default student_ar_fl_controls_ProgressBar_trackSkin
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="trackSkin", type="Class")]
/**
* Name of the class to use as the determinate progress bar.
*
* @default student_ar_fl_controls_ProgressBar_barSkin
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="barSkin", type="Class")]
/**
* Name of the class to use as the indeterminate progress bar. This is passed to the
* indeterminate bar renderer, which is specified by the indeterminateBar
* style.
*
* @default student_ar_fl_controls_ProgressBar_indeterminateSkin
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="indeterminateSkin", type="Class")]
/**
* The class to use as a renderer for the indeterminate bar animation.
* This is an advanced style.
*
* @default fl.controls.progressBarClasses.IndeterminateBar
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="indeterminateBar", type="Class")]
/**
* The padding that separates the progress bar indicator from the track, in pixels.
*
* @default 0
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
[Style(name="barPadding", type="Number", format="Length")]
//--------------------------------------
// Class description
//--------------------------------------
/**
* The student_ar_fl_controls_ProgressBar component displays the progress of content that is
* being loaded. The student_ar_fl_controls_ProgressBar is typically used to display the status of
* images, as well as portions of applications, while they are loading.
* The loading process can be determinate or indeterminate. A determinate
* progress bar is a linear representation of the progress of a task over
* time and is used when the amount of content to load is known. An indeterminate
* progress bar has a striped fill and a loading source of unknown size.
*
* @includeExample examples/student_ar_fl_controls_ProgressBarExample.as
*
* @see student_ar_fl_controls_ProgressBarDirection
* @see student_ar_fl_controls_ProgressBarMode
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public class student_ar_fl_controls_ProgressBar extends UIComponent {
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected var track:DisplayObject;
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected var determinateBar:DisplayObject;
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected var indeterminateBar:UIComponent;
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected var _direction:String = student_ar_fl_controls_ProgressBarDirection.RIGHT;
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected var _indeterminate:Boolean = true;
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected var _mode:String = student_ar_fl_controls_ProgressBarMode.EVENT;
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected var _minimum:Number=0;
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected var _maximum:Number=0;
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected var _value:Number=0;
/**
* @private (protected)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
protected var _source:Object;
/**
* @private (protected)
*/
protected var _loaded:Number;
/**
* @private
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
private static var defaultStyles:Object = {trackSkin:"student_ar_fl_controls_ProgressBar_trackSkin",
barSkin:"student_ar_fl_controls_ProgressBar_barSkin",
indeterminateSkin:"student_ar_fl_controls_ProgressBar_indeterminateSkin",
indeterminateBar:IndeterminateBar,
barPadding:0};
/**
* @copy fl.core.UIComponent#getStyleDefinition()
*
* @includeExample ../core/examples/UIComponent.getStyleDefinition.1.as -noswf
*
* @see fl.core.UIComponent#getStyle()
* @see fl.core.UIComponent#setStyle()
* @see fl.managers.StyleManager
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public static function getStyleDefinition():Object { return defaultStyles; }
/**
* Creates a new student_ar_fl_controls_ProgressBar component instance.
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function student_ar_fl_controls_ProgressBar() {
super();
}
[Inspectable(defaultValue="right",type="list", enumeration="right,left")]
/**
* Indicates the fill direction for the progress bar. A value of
* student_ar_fl_controls_ProgressBarDirection.RIGHT
indicates that the progress
* bar is filled from left to right. A value of student_ar_fl_controls_ProgressBarDirection.LEFT
* indicates that the progress bar is filled from right to left.
*
* @default student_ar_fl_controls_ProgressBarDirection.RIGHT
*
* @includeExample examples/student_ar_fl_controls_ProgressBar.direction.1.as -noswf
*
* @see student_ar_fl_controls_ProgressBarDirection
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function get direction():String {
return _direction;
}
/**
* @private (setter)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function set direction(value:String):void {
_direction = value;
invalidate(InvalidationType.DATA);
}
/**
* Gets or sets a value that indicates the type of fill that the progress
* bar uses and whether the loading source is known or unknown. A value of
* true
indicates that the progress bar has a striped fill
* and a loading source of unknown size. A value of false
* indicates that the progress bar has a solid fill and a loading source
* of known size.
*
*
This property can only be set when the progress bar mode
* is set to student_ar_fl_controls_ProgressBarMode.MANUAL
.
student_ar_fl_controls_ProgressBar.mode
property is set to student_ar_fl_controls_ProgressBarMode.MANUAL
.
*
* @default 0
*
* @see #maximum
* @see #percentComplete
* @see #value
* @see student_ar_fl_controls_ProgressBarMode#MANUAL
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function get minimum():Number {
return _minimum;
}
/**
* @private (setter)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function set minimum(value:Number):void {
if (_mode != student_ar_fl_controls_ProgressBarMode.MANUAL) { return; }
_minimum = value;
invalidate(InvalidationType.DATA);
}
/**
* Gets or sets the maximum value for the progress bar when the
* student_ar_fl_controls_ProgressBar.mode
property is set to student_ar_fl_controls_ProgressBarMode.MANUAL
.
*
* @default 0
*
* @see #minimum
* @see #percentComplete
* @see #value
* @see student_ar_fl_controls_ProgressBarMode#MANUAL
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function get maximum():Number {
return _maximum;
}
/**
* @private (setter)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function set maximum(value:Number):void {
setProgress(_value,value);
}
/**
* Gets or sets a value that indicates the amount of progress that has
* been made in the load operation. This value is a number between the
* minimum
and maximum
values.
*
* @default 0
*
* @see #maximum
* @see #minimum
* @see #percentComplete
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function get value():Number {
return _value;
}
/**
* @private (setter)
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function set value(value:Number):void {
setProgress(value,_maximum);
}
/**
* Sets the state of the bar to reflect the amount of progress made when
* using manual mode. The value
argument is assigned to the
* value
property and the maximum
argument is
* assigned to the maximum
property. The minimum
* property is not altered.
*
* @param value A value describing the progress that has been made.
*
* @param maximum The maximum progress value of the progress bar.
*
* @see #maximum
* @see #value
* @see student_ar_fl_controls_ProgressBarMode#MANUAL student_ar_fl_controls_ProgressBarMode.manual
*
* @langversion 3.0
* @playerversion Flash 9.0.28.0
*/
public function setProgress(value:Number, maximum:Number):void {
if (_mode != student_ar_fl_controls_ProgressBarMode.MANUAL) { return; }
_setProgress(value, maximum);
}
[Inspectable(name="source", type="String")]
/**
* @private (internal)
*/
public function set sourceName(name:String):void {
if (!componentInspectorSetting) { return; }
if (name == "") { return; }
var target:DisplayObject = parent.getChildByName(name) as DisplayObject;
if (target == null) {
throw new Error("Source clip '"+ name +"' not found on parent.");
}
source = target;
}
/**
* Gets or sets a reference to the content that is being loaded and for
* which the student_ar_fl_controls_ProgressBar is measuring the progress of the load operation.
* A typical usage of this property is to set it to a UILoader component.
*
* Use this property only in event mode and polled mode.
* * @default null * * @includeExample examples/student_ar_fl_controls_ProgressBar.source.1.as -noswf * @includeExample examples/student_ar_fl_controls_ProgressBar.source.2.as -noswf * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public function get source():Object { return _source; } /** * @private (setter) * * @langversion 3.0 * @playerversion Flash 9.0.28.0 */ public function set source(value:Object):void { if (_source == value) { return; } if (_mode != student_ar_fl_controls_ProgressBarMode.MANUAL) { resetProgress(); } _source = value; if (_source == null) { return; } // Can not poll or add listeners to a null source! if (_mode == student_ar_fl_controls_ProgressBarMode.EVENT) { setupSourceEvents(); } else if (_mode == student_ar_fl_controls_ProgressBarMode.POLLED) { addEventListener(Event.ENTER_FRAME,pollSource,false,0,true); } } /** * Gets a number between 0 and 100 that indicates the percentage * of the content has already loaded. * *To change the percentage value, use the setProgress()
method.
The following values are valid for this property:
*student_ar_fl_controls_ProgressBarMode.EVENT
student_ar_fl_controls_ProgressBarMode.POLLED
student_ar_fl_controls_ProgressBarMode.MANUAL
Event mode and polled mode are the most common modes. In event mode,
* the source
property specifies loading content that generates
* progress
and complete
events; you should use
* a UILoader object in this mode. In polled mode, the source
* property specifies loading content, such as a custom class, that exposes
* bytesLoaded
and bytesTotal
properties. Any object
* that exposes these properties can be used as a source in polled mode.
You can also use the student_ar_fl_controls_ProgressBar component in manual mode by manually
* setting the maximum
and minimum
properties and
* making calls to the student_ar_fl_controls_ProgressBar.setProgress()
method.