flex中用ProgressBar 进度条加载Image图片进度

来源:互联网 发布:kali linux怎么更新源 编辑:程序博客网 时间:2024/05/21 09:41
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*" creationComplete="init()">
<mx:Script>
 <![CDATA[
 import mx.controls.Image;
 import flash.net.URLLoader;
 import flash.net.URLRequest;
 import mx.controls.Alert;
 import mx.managers.PopUpManager;
 
/*  public var img:Image = new Image(); */
 private var time:Timer = new Timer(1000,1);
 private function init():void
 {
  img.addEventListener(ProgressEvent.PROGRESS,pbRun);
  img.addEventListener(Event.COMPLETE,pbCMPLT);
 }
 
 private function pbCMPLT(e:Event=null):void
 {
  //Alert.show("ok","ok");
  /* time.addEventListener(TimerEvent.TIMER_COMPLETE,timeCpl);  */
  time.start();
 }
 
 /* private function timeCpl(e:TimerEvent=null):void
 {
  PopUpManager.removePopUp(this);
 } */
 
 private function pbRun(e:ProgressEvent):void
 {
  var j:Number;
  j = int(img.bytesLoaded/img.bytesTotal*10000)/100;
  pb.setProgress(j,100);
  pb.label = "DownLoad "+j+"%";
  //pb.label = "";
  
 }
 ]]>
</mx:Script>
 <mx:Image id="img" source="Ddp.swf" width="600" height="520" initialize="init()" y="39"/>
 <mx:ProgressBar id="pb" x="0" y="0" labelPlacement="center" width="800" height="20"  minimum="0" maximum="100" mode="manual" themeColor="#ff0000" color="green"/>
</mx:Application>
原创粉丝点击