| Package | qnx.fuse.ui.progress |
| Class | public class PercentageBar |
| Inheritance | PercentageBar ProgressBar SkinnableComponent UIComponent flash.display.MovieClip |
PercentageBar class shows activity progress by percentage.
PercentageBar class extends the ProgressBar class
to provide a text label that outputs the current percentage value.
See also
| Property | Defined By | ||
|---|---|---|---|
![]() | explicitHeight : Number [read-only] | UIComponent | |
![]() | explicitWidth : Number [read-only] | UIComponent | |
![]() | includeInLayout : Boolean
Specifies if the component should be included in it's parent containers layout. | UIComponent | |
| label : String
Sets the label for the progress value. | PercentageBar | ||
![]() | layoutData : Object
Returns the layout data for the object. | UIComponent | |
![]() | minHeight : Number
Sets the minimum preferred height of the control. | UIComponent | |
![]() | minWidth : Number
Sets the minimum preferred width of the control. | UIComponent | |
![]() | progress : Number
Gets or sets the current progress value as indicated by the progress bar. | ProgressBar | |
| showPercent : Boolean
A Boolean that toggles the percentage value label. | PercentageBar | ||
![]() | state : String
Gets or sets the state of the component. | SkinnableComponent | |
| Method | Defined By | ||
|---|---|---|---|
Creates a new ProgressBar instance. | PercentageBar | ||
![]() | childChanged(resizedChild:DisplayObject = null):Boolean
Notifies the UIComponent that one or more of its children has changed in a manner
that may affect this object's layout. | UIComponent | |
![]() | destroy():void
Call this method when you want to have your object collected by the garbage collector. | UIComponent | |
![]() | getSizeOptions():int | UIComponent | |
![]() | invalidateDisplayList():void
Calling this method results in a call to the components validateDisplayList() method before the display list is rendered. | UIComponent | |
![]() | invalidateProperties():void
Calling this method results in a call to the components validateProperties() method before the display list is rendered. | UIComponent | |
![]() | measure(availableWidth:Number, availableHeight:Number):LayoutMeasurement | UIComponent | |
![]() | setActualSize(w:Number, h:Number):void
Sets the width and height of the object without setting
the explicitWidth and explicitHeight. | UIComponent | |
![]() | setLayoutBounds(bounds:Rectangle):void
Sets the receiver's size and location to the rectangular area specified
by the arguments. | UIComponent | |
![]() | setPosition(x:Number, y:Number):void
Sets the x and y position of the component. | UIComponent | |
![]() | setSkin(newSkin:Object):void [override]
Set the skin object on the progress bar for it to render. | ProgressBar | |
setTextFormat(format:TextFormat):void
Set the TextFormat for the item. | PercentageBar | ||
![]() | validateDisplayList():void
Validates the display list of the component by calling the updateDisplayList(). | UIComponent | |
![]() | validateNow():void
Validates the component immediately by calling validateProperties(), validateSizes(), and validateDisplayList() if necessary. | UIComponent | |
![]() | validateProperties():void
Validates the properties of the component by calling the commitProperties() method. | UIComponent | |
| label | property |
label:String
Sets the label for the progress value. If set after the showPercent value, this value will override
the showPercent property.
The following listing uses a PercentageBar to display a status message during a load operation:
myPercentage = new PercentageBar();
myPercentage.setPosition(400, 300);
myPercentage.width = 200;
myPercentage.height = 30;
myPercentage.progress = 0;
myPercentage.setTextFormat(percentFormat);
myPercentage.label = "Loading..."
public function get label():String public function set label(value:String):void| showPercent | property |
showPercent:BooleanA Boolean that toggles the percentage value label.
The default value is true.
public function get showPercent():Boolean public function set showPercent(value:Boolean):void| PercentageBar | () | Constructor |
public function PercentageBar()
Creates a new ProgressBar instance.
| setTextFormat | () | method |
public function setTextFormat(format:TextFormat):void
Set the TextFormat for the item. The TextFormat object defines the text formatting
for the percentage label. In the following listing, a TextFormat object is instantiated and applied to the
PercentageBar:
var percentlFormat:TextFormat = new TextFormat();
percentlFormat.size = 20;
percentlFormat.bold = true;
percentlFormat.italic = true;
myPercentage.setTextFormat(percentlFormat);
this.addChild(myPercentage);
Parameters
format:TextFormat — The TextFormat object to apply to the label.
|
PercentageBar instance. It contains a simple timer routine that is
used to update the progress value.
package
{
import flash.display.Sprite;
import flash.events.TimerEvent;
import flash.utils.Timer;
import qnx.fuse.ui.progress.PercentageBar;
[SWF(height="600", width="1024",
frameRate="30", backgroundColor="#FFFFFF")]
public class PercentBarSample extends Sprite
{
private var myPercentage:PercentageBar;
private var timer:Timer;
private var counter:int;
public function PercentBarSample()
{
initializeUI();
}
private function initializeUI():void{
myPercentage = new PercentageBar();
myPercentage.setPosition(400, 300);
myPercentage.width = 200;
myPercentage.height = 10;
myPercentage.progress = 0;
this.addChild(myPercentage);
// counter to keep track of how many times the timer has ticked
counter = 0;
timer = new Timer(100,100);
timer.addEventListener(TimerEvent.TIMER,handleTimerTick);
timer.addEventListener(TimerEvent.TIMER_COMPLETE,handleTimerComplete);
timer.start();
}
private function handleTimerComplete(e:TimerEvent):void
{
timer.removeEventListener(TimerEvent.TIMER,handleTimerTick);
timer.removeEventListener(TimerEvent.TIMER_COMPLETE,handleTimerComplete);
counter = 0;
}
private function handleTimerTick( e:TimerEvent ):void
{
counter++;
myPercentage.progress = counter/100;
}
}
}