<mx:Script>
<![CDATA[
import flash.net.FileReference;
import mx.controls.Alert;
import mx.events.CloseEvent;
import flash.events.*;
public var file:FileReference;
private function init():void{
//var file:FileReference;
Security.allowDomain("*");
file = new FileReference();
file.addEventListener(ProgressEvent.PROGRESS, onProgress);
file.addEventListener(Event.SELECT, onSelect);
}
private function upload():void{
file.browse();
}
private function onSelect(e:Event):void{
Alert.show("上传 " + file.name + " (共 "+Math.round(file.size)+" 字节)?",
"确认上传",
Alert.YES|Alert.NO,
null,
proceedWithUpload);
}
private function onProgress(e:ProgressEvent):void{
lbProgress.text = " 已上传 " + e.bytesLoaded
+ " 字节,共 " + e.bytesTotal + " 字节";
}
private function proceedWithUpload(e:CloseEvent):void{
if (e.detail == Alert.YES){
file.upload("
http://localhost/WebApplication1/WebForm1.aspx");
}
}
]]>
</mx:Script>