包 | fl.controls |
类 | public class ProgressBarMode |
继承 | ProgressBarMode Object |
语言版本 : | ActionScript 3.0 |
Player 版本 : | Flash Player 9.0.28.0 |
mode
属性值。
另请参见
常量 | 定义方 | ||
---|---|---|---|
EVENT : String = "event" [static]
由 source 属性指定的组件必须调度 progress 和 complete 事件。
| ProgressBarMode | ||
MANUAL : String = "manual" [static]
手动更新 ProgressBar 组件的状态。
| ProgressBarMode | ||
POLLED : String = "polled" [static]
可通过对源进行轮询来更新进度。
| ProgressBarMode |
EVENT | 常量 |
public static const EVENT:String = "event"
语言版本 : | ActionScript 3.0 |
Player 版本 : | Flash Player 9.0.28.0 |
由 source
属性指定的组件必须调度 progress
和 complete
事件。 ProgressBar 使用这些事件更新其状态。
另请参见
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 | 常量 |
public static const MANUAL:String = "manual"
语言版本 : | ActionScript 3.0 |
Player 版本 : | Flash Player 9.0.28.0 |
手动更新 ProgressBar 组件的状态。 在此模式下,指定 minimum
和 maximum
属性,并使用 setProgress()
方法指定状态。
另请参见
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 | 常量 |
public static const POLLED:String = "polled"
语言版本 : | ActionScript 3.0 |
Player 版本 : | Flash Player 9.0.28.0 |
可通过对源进行轮询来更新进度。 source
属性必须指定一个用来公开 bytesLoaded
和 bytesTotal
属性的对象。
另请参见
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:*) { // } }
当前页: http://livedocs.adobe.com/flash/9.0_cn/ActionScriptLangRefV3/fl/controls/ProgressBarMode.html