套件 | fl.controls |
類別 | public class ProgressBarMode |
繼承 | ProgressBarMode Object |
語言版本: | ActionScript 3.0 |
產品版本: | Flash CS3 |
執行階段版本: | Flash Player 9.0.28.0, AIR 1.0 |
mode
屬性值。
相關 API 元素
公用常數
常數 | 定義自 | ||
---|---|---|---|
EVENT : String = "event" [靜態]
source 屬性所指定的組件必須傳送 progress 和 complete 事件。 | ProgressBarMode | ||
MANUAL : String = "manual" [靜態]
手動更新 ProgressBar 組件狀態。 | ProgressBarMode | ||
POLLED : String = "polled" [靜態]
透過輪詢來源更新進度。 | ProgressBarMode |
常數詳細資訊
EVENT | 常數 |
public static const EVENT:String = "event"
語言版本: | ActionScript 3.0 |
產品版本: | Flash CS3 |
執行階段版本: | Flash Player 9.0.28.0, AIR 1.0 |
source
屬性所指定的組件必須傳送 progress
和 complete
事件。 ProgressBar 會使用這些事件更新其狀態。
相關 API 元素
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
範例 ( 如何使用本範例 )
下列範例會建立 ProgressBar、Label 和 UILoader 組件實體,並顯示影像的載入進度:
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 |
產品版本: | Flash CS3 |
執行階段版本: | Flash Player 9.0.28.0, AIR 1.0 |
手動更新 ProgressBar 組件狀態。 在此模式下,您可以指定 minimum
和 maximum
屬性,並使用 setProgress()
方法來指定狀態。
相關 API 元素
範例 ( 如何使用本範例 )
下列範例會建立 ProgressBar 和 Label 組件實體,以顯示進度列的狀態:
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 |
產品版本: | Flash CS3 |
執行階段版本: | Flash Player 9.0.28.0, AIR 1.0 |
透過輪詢來源更新進度。 source
屬性必須指定會公開 bytesLoaded
和 bytesTotal
屬性的物件。
相關 API 元素
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
範例 ( 如何使用本範例 )
下列範例會使用 ProgressBar,顯示 FLV 檔的載入進度:
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:*) { // } }
Tue Jun 12 2018, 03:47 PM Z