Package | fl.controls |
Class | public class ProgressBarMode |
Inheritance | ProgressBarMode ![]() |
Language Version : | ActionScript 3.0 |
Player Version : | Flash Player 9.0.28.0 |
mode
property of the ProgressBar class.
See also
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 |
EVENT | Constant |
public static const EVENT:String = "event"
Language Version : | ActionScript 3.0 |
Player Version : | Flash Player 9.0.28.0 |
The component specified by the source
property must dispatch
progress
and complete
events. The ProgressBar uses these events to update its status.
See also
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 |
Player Version : | Flash Player 9.0.28.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.
See also
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 |
Player Version : | Flash Player 9.0.28.0 |
Progress is updated by polling the source. The source
property must specify an object that exposes the bytesLoaded
and bytesTotal
properties.
See also
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:*) { // } }