(Beta)
Package | fl.controls |
Class | public class ProgressBarMode |
Inheritance | ProgressBarMode Object |
Language Version: | ActionScript 3.0 |
Product Version: | Flash CS3 |
Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0 |
mode
property of the ProgressBar class.
Related API Elements
Public Properties
Public Methods
Public Constants
Constant | Defined By | ||
---|---|---|---|
EVENT : String = "event" [static]
The component specified by the source property must dispatch
progress and complete
events. | ProgressBarMode | ||
MANUAL : String = "manual" [static]
Manually update the status of the ProgressBar component. | ProgressBarMode | ||
POLLED : String = "polled" [static]
Progress is updated by polling the source. | ProgressBarMode |
Constant Detail
EVENT | Constant |
public static const EVENT:String = "event"
Language Version: | ActionScript 3.0 |
Product Version: | Flash CS3 |
Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0 |
The component specified by the source
property must dispatch
progress
and complete
events. The ProgressBar uses these events to update its status.
Related API Elements
ScrollPane complete event
ScrollPane progress event
UILoader complete event
UILoader progress event
LoaderInfo complete event
LoaderInfo progress event
Sound complete event
Sound progress event
FileReference complete event
FileReference progress event
URLLoader complete event
URLLoader progress event
URLStream complete event
URLStream progress event
ScrollPane progress event
UILoader complete event
UILoader progress event
LoaderInfo complete event
LoaderInfo progress event
Sound complete event
Sound progress event
FileReference complete event
FileReference progress event
URLLoader complete event
URLLoader progress event
URLStream complete event
URLStream progress event
Example ( How to use this example )
The following example creates ProgressBar, Label and UILoader component instances and displays the loading progress of an image:
import fl.containers.UILoader; import fl.controls.Label; import fl.controls.ProgressBar; import fl.controls.ProgressBarMode; import fl.events.ComponentEvent; var url:String = "http://www.helpexamples.com/flash/images/image2.jpg"; var myUILoader:UILoader = new UILoader(); myUILoader.visible = false; myUILoader.scaleContent = false; myUILoader.autoLoad = false; myUILoader.source = url; myUILoader.addEventListener(ComponentEvent.RESIZE, resizeHandler); myUILoader.load(); var myProgressBar:ProgressBar = new ProgressBar(); myProgressBar.mode = ProgressBarMode.EVENT; myProgressBar.indeterminate = false; myProgressBar.source = myUILoader; myProgressBar.setSize(320, 12); myProgressBar.move((stage.stageWidth - myProgressBar.width) / 2, (stage.stageHeight - myProgressBar.height) / 2); myProgressBar.addEventListener(Event.COMPLETE, completeHandler); myProgressBar.addEventListener(ProgressEvent.PROGRESS, progressHandler); addChild(myProgressBar); var myLabel:Label = new Label(); myLabel.text = ""; myLabel.autoSize = TextFieldAutoSize.LEFT; myLabel.move(myProgressBar.x, myProgressBar.y + myProgressBar.height); addChild(myLabel); function progressHandler(event:ProgressEvent):void { trace("progress:", event.bytesLoaded, "of", event.bytesTotal, "bytes"); myLabel.text = event.bytesLoaded + " of " + event.bytesTotal + " (" + event.currentTarget.percentComplete.toFixed(1) + "%)"; } function completeHandler(event:Event):void { trace("complete:"); removeChild(myLabel); removeChild(myProgressBar); myProgressBar.removeEventListener(ProgressEvent.PROGRESS, progressHandler); myProgressBar.removeEventListener(Event.COMPLETE, completeHandler); addChild(myUILoader); } function resizeHandler(event:ComponentEvent):void { trace("resize:"); var myUILdr:UILoader = event.currentTarget as UILoader; myUILdr.move((stage.stageWidth - myUILdr.width) / 2, (stage.stageHeight - myUILdr.height) / 2); myUILdr.visible = true; }
MANUAL | Constant |
public static const MANUAL:String = "manual"
Language Version: | ActionScript 3.0 |
Product Version: | Flash CS3 |
Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0 |
Manually update the status of the ProgressBar component. In this mode, you specify the
minimum
and maximum
properties and use the
setProgress()
method to specify the status.
Related API Elements
Example ( How to use this example )
The following example creates ProgressBar and Label component instances to display the progress bar's status:
import fl.controls.Label; import fl.controls.ProgressBar; import fl.controls.ProgressBarMode; var myProgressBar:ProgressBar = new ProgressBar(); myProgressBar.indeterminate = false; myProgressBar.mode = ProgressBarMode.MANUAL; myProgressBar.maximum = 256; myProgressBar.setSize(320, 16); myProgressBar.move(10, 10) addChild(myProgressBar); var myLabel:Label = new Label(); myLabel.text = ""; myLabel.autoSize = TextFieldAutoSize.LEFT; myLabel.move(myProgressBar.x, myProgressBar.y + myProgressBar.height); addChild(myLabel); var t:Timer = new Timer(150); t.addEventListener(TimerEvent.TIMER, timerHandler); t.start(); function timerHandler(event:TimerEvent):void { myProgressBar.setProgress(myProgressBar.value + 1, myProgressBar.maximum); if (myProgressBar.percentComplete == 100) { myProgressBar.setProgress(0, myProgressBar.maximum); } myLabel.text = int(myProgressBar.value) + " of " + int(myProgressBar.maximum) + " (" + int(myProgressBar.percentComplete) + "%)"; }
POLLED | Constant |
public static const POLLED:String = "polled"
Language Version: | ActionScript 3.0 |
Product Version: | Flash CS3 |
Runtime Versions: | Flash Player 9.0.28.0, AIR 1.0 |
Progress is updated by polling the source. The source
property must specify an object that exposes the bytesLoaded
and bytesTotal
properties.
Related API Elements
ScrollPane.bytesLoaded
ScrollPane.bytesTotal
UILoader.bytesLoaded
UILoader.bytesTotal
Sound.bytesLoaded
Sound.bytesTotal
NetStream.bytesLoaded
NetStream.bytesTotal
URLLoader.bytesLoaded
URLLoader.bytesTotal
ScrollPane.bytesTotal
UILoader.bytesLoaded
UILoader.bytesTotal
Sound.bytesLoaded
Sound.bytesTotal
NetStream.bytesLoaded
NetStream.bytesTotal
URLLoader.bytesLoaded
URLLoader.bytesTotal
Example ( How to use this example )
The following example uses the ProgressBar to display the loading progress of an FLV file:
import fl.controls.ProgressBar; import fl.controls.ProgressBarMode; var url:String = "http://www.helpexamples.com/flash/video/cuepoints.flv"; var nc:NetConnection = new NetConnection(); nc.connect(null); var ns:NetStream = new NetStream(nc); ns.client = {onMetaData:metaDataHandler}; ns.play(url); var vid:Video = new Video(); vid.attachNetStream(ns); vid.x = (stage.stageWidth - vid.width) / 2; vid.y = (stage.stageHeight - vid.height) / 2; addChild(vid); var myProgressBar:ProgressBar = new ProgressBar(); myProgressBar.mode = ProgressBarMode.POLLED; myProgressBar.indeterminate = false; myProgressBar.source = ns; myProgressBar.setSize(vid.width, myProgressBar.height); myProgressBar.move(vid.x, vid.y + vid.height); addChild(myProgressBar); function metaDataHandler(meta:Object):void { try { trace("w:" + meta.width, "h:" + meta.height); vid.width = meta.width; vid.height = meta.height; vid.x = (stage.stageWidth - vid.width) / 2; vid.y = (stage.stageHeight - vid.height) / 2; myProgressBar.width = vid.width; myProgressBar.move(vid.x, vid.y + vid.height); } catch (error:*) { // } }
Wed Nov 21 2018, 06:34 AM -08:00