trace("false");
}else if (filesize <= _maxFileSize){
r = true;
trace("true");
}
if (_maxFileSize == 0){
r = true;
}
return r;
}
// restores progress bar back to normal
private function resetProgressBar():void{
_progressbar.label = "";
_progressbar.maximum = 0;
_progressbar.minimum = 0;
}
// reset form item elements
private function resetForm():void{
_uploadbutton.enabled = false;
_uploadbutton.addEventListener(MouseEvent.CLICK,uploadFiles);
_uploadbutton.label = "Upload";
_progressbar.maximum = 0;
_totalbytes = 0;
_progressbar.label = "";
_remselbutton.enabled = false;
_remallbutton.enabled = false;
_browsebutton.enabled = true;
}
// whenever the _files arraycollection changes this function is called to make sure the datagrid data jives
private function popDataGrid(event:CollectionEvent):void{
getByteCount();
checkCue();
}
// enable or disable upload and remove controls based on files in the cue;
private function checkCue():void{
if (_files.length > 0){
_uploadbutton.enabled = true;
_remselbutton.enabled = true;
_remallbutton.enabled = true;
}else{
resetProgressBar();
_uploadbutton.enabled = false;
}
}
// toggle upload button label and function to trigger file uploading or upload cancelling
private function setupCancelButton(x:Boolean):void{
if (x == true){
_uploadbutton.label = "Cancel";
_browsebutton.enabled = false;
_remselbutton.enabled = false;
_remallbutton.enabled = false;
_uploadbutton.addEventListener(MouseEvent.CLICK,cancelFileIO);
}else if (x == false){
_uploadbutton.removeEventListener(MouseEvent.CLICK,cancelFileIO);
resetForm();
}
}
/*********************************************************
* File IO Event Handlers *
*********************************************************/
// called after user selected files form the browse dialouge box.
private function selectHandler(event:Event):void {
var i:int;
var msg:String ="";
var dl:Array = [];
for (i=0;i < event.currentTarget.fileList.length; i ++){
if (checkFileSize(event.currentTarget.fileList[i].size)){
_files.addItem(event.currentTarget.fileList[i]);
trace("under size " + event.currentTarget.fileList[i].size);
} else {
dl.push(event.currentTarget.fileList[i]);
trace(event.currentTarget.fileList[i].name + " too large");
}
}
if (dl.length > 0){
for (i=0;i
msg += String(dl[i].name + " is too large. \n");
}
mx.controls.Alert.show(msg + "Max File Size is: " + Math.round(_maxFileSize / 1024) + " kb","File Too Large",4,null).clipContent;