4,328
社区成员
发帖
与我相关
我的任务
分享
protected function btn_dload_clickHandler(event:MouseEvent):void
{
var SowURL:URLRequest=new URLRequest(TestConstants.SERVER_PATH + "/fileassets/test.ppt");
var fileR:FileReference=new FileReference();
fileR.addEventListener(ProgressEvent.PROGRESS, downloadProgress);
fileR.addEventListener(Event.COMPLETE, drowloadComplete);
fileR.addEventListener(IOErrorEvent.IO_ERROR, downLoadError);
configFileDownload(fileR);
fileR.download(SowURL);
}
public function drowloadComplete(event:Event):void
{
PopUpManager.removePopUp(bar);
}
public function downLoadError(event:Event):void
{
var fileR:FileReference=event.currentTarget as FileReference;
fileR.removeEventListener(ProgressEvent.PROGRESS, downloadProgress);
var alert4:AlertPanel=new AlertPanel();
alert4.txtStr=resourceManager.getString(RmsConstants.LOCALE_FILE_NAME, "DOWNLOAD_FAILURE");
PopUpManager.addPopUp(alert4, this, true);
PopUpManager.centerPopUp(alert4);
}
public function downloadProgress(event:ProgressEvent):void
{
//test.label="已上传 " + Math.round(100 * event.bytesLoaded / event.bytesTotal) + "%";
try
{
if (uploadFlag)
{
bar=new ProgressBar;
bar.height=2;
bar.width=200;
bar.minimum=0;
bar.visible=true;
bar.maximum=100;
bar.direction="right"
bar.mode="manual";
PopUpManager.addPopUp(bar, this, true);
PopUpManager.centerPopUp(bar);
uploadFlag=false;
}
}
catch (e:Error)
{
Alert.show("Upload PPT file failed", "Message", Alert.OK);
}
var proc:uint=event.bytesLoaded / event.bytesTotal * 100;
bar.setProgress(proc, 100);
bar.label="Progress : " + " " + (proc - 1) + "%";
}
/**
*
* 文件下载全程监听配置
*
**/
private function configFileDownload(eventDispatcher:IEventDispatcher):void
{
}