}
}
// called after the file is opened before upload
private function openHandler(event:Event):void{
trace('openHandler triggered');
_files;
}
// called during the file upload of each file being uploaded | we use this to feed the progress bar its data
private function progressHandler(event:ProgressEvent):void {
_progressbar.setProgress(event.bytesLoaded,event.bytesTotal);
_progressbar.label = "Uploading " + Math.round(event.bytesLoaded / 1024) + " kb of " + Math.round(event.bytesTotal / 1024) + " kb " + (_files.length - 1) + " files remaining";
}
// called after a file has been successully uploaded | we use this as well to check if there are any files left to upload and how to handle it
private function completeHandler(event:Event):void{
//trace('completeHanderl triggered');
_files.removeItemAt(0);
if (_files.length > 0){
_totalbytes = 0;
uploadFiles(null);
}else{
setupCancelButton(false);
_progressbar.label = "Uploads Complete";
var uploadCompleted:Event = new Event(Event.COMPLETE);
dispatchEvent(uploadCompleted);
}
}
// only called if there is an error detected by flash player browsing or uploading a file
private function ioErrorHandler(event:IOErrorEvent):void{
//trace('And IO Error has occured:' + event);
mx.controls.Alert.show(String(event),"ioError",0);
}
// only called if a security error detected by flash player such as a sandbox violation
private function securityErrorHandler(event:SecurityErrorEvent):void{
//trace("securityErrorHandler: " + event);
mx.controls.Alert.show(String(event),"Security Error",0);
}
// This function its not required
private function cancelHandler(event:Event):void{
// cancel button has been clicked;
trace('cancelled');
}
// after a file upload is complete or attemted the server will return an http status code, code 200 means all is good anything else is bad.
private function httpStatusHandler(event:HTTPStatusEvent):void {
// trace("httpStatusHandler: " + event);
if (event.status != 200){
mx.controls.Alert.show(String(event),"Error",0);
}
}
}
}
上传工具了,非常好用,大家试试吧.