真才实料才是最真

Dream have no limit

统计

积分与排名

good link

最新评论

flex2 FileReference download

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
 
 <mx:Script>
  <![CDATA[
  
     public var fileRe:FileReference=new FileReference() 
    
     private var file:FileReference;      
     private var currentAction:String;
     private var downloadURL:URLRequest;
 
                
     private function download():void{ 
    
     var url:URLRequest=new URLRequest("http://localhost:8000/flex_fileupload/upload/handanda.txt");
      file = new FileReference();
      fileRe.addEventListener(Event.COMPLETE,comple)
      fileRe.addEventListener(ProgressEvent.PROGRESS,jindu)     
      fileRe.download(url)

     }
    
     private function jindu(e:ProgressEvent):void{
     var load:Number=e.bytesLoaded
     var toal:Number=e.bytesTotal
     var per:Number=Math.round(load/toal*100)
     trace(per)
  //tex.text=String(per)
     }
    
     private function comple(e:Event):void{
     tex.text="已下载完成!"
     }

  ]]>
 </mx:Script>
 
 <mx:Button  x="10" y="20" label="下载一个文件" click="download()"/>
 <mx:ProgressBar x="10" y="100" id="progress" source="fileRe" label="已加载: %3%%"/>
 <mx:Text text="" x="10" y="105" id="tex"/>

</mx:Application>

posted on 2007-09-03 15:35 gavinkin555 阅读(861) 评论(0)  编辑 收藏 引用 所属分类: FLEX

只有注册用户登录后才能发表评论。