uploadScript.as

Summary
uploadScript.as
Variables
bytesUploadedNumber of bytes that have been uploaded.
numUploadsNumber of uploads in this session.
currentUploadFile that is currently being uploaded.
uploadFileRefListFile Reference List of files to be uploaded.
queueQueue containing the files to upload.
eventHandledUsed to determine if the event has been handled in the event that multiple events will be thrown from one error.
Functions
uploadFilesDisplays the file selector and initiates the file upload.
uploadSelectHandlerCalled when a user selects files from the File Select box created in the uploadFiles function.
doUploadAdds event listeners to the local file, formats the variables to be passed to the upload, and initiates the file upload.
uploadCompleteHandlerCalled when a file upload is completed.
uploadOpenHandlerCalled when a upload is initiated.
uploadHTTPStatusHandlerDisplays an error alert, and sets the eventHandled variable to true.
uploadIoErrorHandlerDisplays an error message and progresses to the next file.
cleanupFileRemoves the event listeners.
progressToNextFileTriggers a cleanup on the current file, and initiates the upload of the next file.

Variables

bytesUploaded

private var bytesUploaded: Number

Number of bytes that have been uploaded.

numUploads

private var numUploads: Number

Number of uploads in this session.

currentUpload

private var currentUpload: compu.UploadFile

File that is currently being uploaded.

uploadFileRefList

private var uploadFileRefList: FileReferenceList

File Reference List of files to be uploaded.

queue

private var queue: ArrayCollection

Queue containing the files to upload.

eventHandled

private var eventHandled: Boolean

Used to determine if the event has been handled in the event that multiple events will be thrown from one error.

Functions

uploadFiles

private function uploadFiles():void

Displays the file selector and initiates the file upload.

uploadSelectHandler

private function uploadSelectHandler(event: Event):void

Called when a user selects files from the File Select box created in the uploadFiles function.  The function checks the files, adds them to the upload queue, and initiates the upload process.

doUpload

private function doUpload(data: compu.UploadFile):void

Adds event listeners to the local file, formats the variables to be passed to the upload, and initiates the file upload.

Parameters

fileReference to the local file.

uploadCompleteHandler

private function uploadCompleteHandler (event: Event):void

Called when a file upload is completed.  Updates the tile list, and progresses to the next file.

Parameters

eventUpload complete event.

See Also

doUpload progressToNextFile

uploadOpenHandler

private function uploadOpenHandler(event: Event):void

Called when a upload is initiated.  Sets the direction of the progress bar.  Primarily kept to ease if new functions have to be added on open.

Parameters

eventEvent when file upload is opened.

uploadHTTPStatusHandler

private function uploadHTTPStatusHandler(event: HTTPStatusEvent):void

Displays an error alert, and sets the eventHandled variable to true.  The error is cleaned up in the uploadIoErrorHandler function, as IO errors are thrown following http errors.

Parameters

eventHTTP Error Status event.

uploadIoErrorHandler

private function uploadIoErrorHandler(event: Event):void

Displays an error message and progresses to the next file.

Parameters

eventIO Error event.

cleanupFile

private function cleanupFile(file: FileReference):void

Removes the event listeners.

Parameters

fileReference to the uploaded file to be cleaned up.

progressToNextFile

private function progressToNextFile(file: FileReference):void

Triggers a cleanup on the current file, and initiates the upload of the next file.  If there are no more files, ends the current upload session.

Parameters

fileReference to the current file that was uploaded.
private var bytesUploaded: Number
Number of bytes that have been uploaded.
private var numUploads: Number
Number of uploads in this session.
private var currentUpload: compu.UploadFile
File that is currently being uploaded.
private var uploadFileRefList: FileReferenceList
File Reference List of files to be uploaded.
private var queue: ArrayCollection
Queue containing the files to upload.
private var eventHandled: Boolean
Used to determine if the event has been handled in the event that multiple events will be thrown from one error.
private function uploadFiles():void
Displays the file selector and initiates the file upload.
private function uploadSelectHandler(event: Event):void
Called when a user selects files from the File Select box created in the uploadFiles function.
private function doUpload(data: compu.UploadFile):void
Adds event listeners to the local file, formats the variables to be passed to the upload, and initiates the file upload.
private function uploadCompleteHandler (event: Event):void
Called when a file upload is completed.
private function uploadOpenHandler(event: Event):void
Called when a upload is initiated.
private function uploadHTTPStatusHandler(event: HTTPStatusEvent):void
Displays an error alert, and sets the eventHandled variable to true.
private function uploadIoErrorHandler(event: Event):void
Displays an error message and progresses to the next file.
private function cleanupFile(file: FileReference):void
Removes the event listeners.
private function progressToNextFile(file: FileReference):void
Triggers a cleanup on the current file, and initiates the upload of the next file.