Flex进度条的使用
例1: mxml文件中的使用方法
<?xml version="1.0" encoding="utf-8"?><s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" creationComplete="InitApp()" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" width="435" height="208"><fx:Script><![CDATA[import mx.controls.Alert;import mx.controls.Image;import flash.net.URLLoader;import flash.net.URLRequest;import mx.managers.PopUpManager;import mx.controls.ProgressBar;private var valueNum:Number = 0;//使用定时器处理progressBar 开始private var timer:Timer;protected function InitApp():void{timer = new Timer(1); timer.addEventListener(TimerEvent.TIMER, OnTimeEvent);timer.start();}private function OnTimeEvent(evt:TimerEvent):void{valueNum = valueNum + 10;var vaPercent:Number = valueNum / 100;if(valueNum >= 10000){progressBar.setProgress(valueNum, 10000);progressBar.label = "download completed";return;}progressBar.setProgress(valueNum, 10000);progressBar.label = vaPercent + "% has been downloaded" }]]></fx:Script><mx:ProgressBar x="108" y="22" label="0% has been downloaded" minimum="0" maximum="100" mode="manual" id="progressBar" name="progress" indeterminate="false" enabled="true" chromeColor="#1F1616" color="#FB0D0D" disabledColor="#FA1919" errorColor="#26AE4D"/></s:Application>?
?
?
例2: as文件中的使用方法
?
var proBar:ProgressBar = new ProgressBar();proBar.width = 48;proBar.x = 0;proBar.y = 0;proBar.minimum = 0;proBar.maximum = 100;proBar.direction = "right";proBar.mode = "manual";this.addChild(proBar);var timer:Timer;var valueNum:Number = 0;timer = new Timer(1); timer.addEventListener(TimerEvent.TIMER, function():void{valueNum = valueNum + 10;var vaPercent:Number = valueNum / 100;if(valueNum >= 10000){proBar.setProgress(valueNum, 10000);proBar.label = "同步完成";proBar.visible = false;return;}proBar.setProgress(valueNum, 10000);proBar.label = "已经同步" + vaPercent + "%"; });timer.start();?