The EAFlashUpload fires a number of events. These events describe user interaction with EAFlashUpload, indicate changes of upload queue, provide information of upload state.
To handle EAFlashUpload events you can use predefined handlers or assign new handler at the initialization stage. The predefined handlers has the following format:
function <EAFlashUpload_ID>_<EventName>() { }
- EAFlashUpload_ID - a value of id attribute defined for EAFlashUpload on the page. Below in the documentation, we assume that id is "EAFlashUpload", but your final solution may have any value.
- EventName - a name of appropriate event
List of events
Event name | Description |
---|---|
onMovieLoad | Fires after EAFlashUpload have been initialized. |
onFilesAdded | Fires when files are added to the upload queue. |
onFilesRemoved | Fires when files are removed from the upload queue. |
onFilesSorted | Fires when files are sorted in the upload queue. |
onQueueChanged | Fires when upload queue is changed due to some actions. |
onItemSelected | Fires when a different files is selected in the upload queue. |
onUploadStart | Fires when upload begins. |
onUploadEnd | Fires when upload is completed. |
onUploadCancel | Fires when upload is canceled by the user or JavaScript method calling. |
onFileLoadStart | Fires when a file upload operation starts. |
onFileLoadEnd | Fires when a file upload is successfully completed. |
onUploadProgress | Dispatched periodically during the file upload. |
onUploadError | Dispatched if errors occur during upload operation. |
onQueueError | Fires when files are restricted due to some queue limitations. |
onSystemError | Fires when various system error occur. |
onAsyncRequestStart | Fires when asynchronous request starts. |
onAsyncRequestEnd | Fires when asynchronous request is successfully completed. |
onAsyncRequestError | Fires when some error occur during asynchronous request. |
onImageViewResize | Fires when ImageView is loaded on the page and every time when ImageView sizes are changed dynamically. |
onImagesAdded | Fires when preview images are added to imagesList. |
onResizedImagesUploadStart | Fires when uploading of resized images is started. |
onResizedImagesUploadEnd | Fires when uploading of resized images has been finished. |
onOriginalImagesUploadStart | Fires when uploading of original images begins. |
onOriginalImagesUploadEnd | Fires when uploading of original images is successfully completed. |
onMovieLoad(errors)
Parameters:
- errors:Array - a string array containing a string representation of errors occured during control initialization;
Description:
Fires after EAFlashUpload have been initialized. Any interaction with the EAFlashUpload should be archived after this event only. Inside handler of this event you can define custom events handler if you don't want to use predefined.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onMovieLoad(errors) { alert(errors); // define a custom event handler for onUploadStart event EAFlashUpload.onUploadStart = customHandler; } function customHandler() { // appropriate operations }
onFilesAdded(filesIds:Array)
Parameters:
- filesIds:Array - an array of unique identifiers of added files;
Description:
Fires when the user selects files for upload from the file-browsing dialog box.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onFilesAdded(filesIds) { var addedFiles = EAFlashUpload.getFiles(filesIds); var someDivElement = document.getElementById("DIV_NamesOfFiles"); var filesNames = ""; for(var i = 0; i < addedFiles.length; i++) { filesNames += addedFiles[i].name + "<br />"; } someDivElement.innerHTML = filesNames; }
onFilesRemoved(files:Array)
Parameters:
- files:Array - an array of File objects;
Description:
Fires when files are deleted from the upload queue. files array contains removed files.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onFilesRemoved(files) { alert(files.length + " files have benn deleted!"); }
onFilesSorted(fieldName:String, isSortDescending:Boolean)
Parameters:
- fieldName:String - a name of the column to be sorted;
- isSortDescending:Boolean - A value of true indicates that the column is sorted in descending order; a value of false indicates that the column is sorted in ascending order;
Description:
Fires when files are sorted in the upload queue. This event is used to indicate a change in the order of the data, not a change in the data itself.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onFilesSorted(fieldName, isSortDescending) { alert("The files have benn sorted by " + fieldName + "column in " + (isSortDescending)?"descending ":"ascending" + "order."); }
onQueueChanged(changeType:String)
Parameters:
-
changeType:String - a type of changes. Possible values are:
- "sort" - the upload queue was sorted;
- "add" - files were added to the upload queue;
- "remove" - files were removed from the upload queue;
- "removeAll" - all files were removed from the upload queue;
Description:
Fires when upload queue is changed due to some actions. The event is dispatched after appropriate operation was done.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onQueueChanged(changeType) { alert("The upload queue have been changed!"); }
onItemSelected(selectedIndices:Array)
Parameters:
- selectedIndices:Array - an array of selected files indices;
Description:
Fires when a different files is selected in the upload queue. This event is dispatched when user select rows of fileList element of the TableView or ListView only.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onItemSelected(selectedIndices) { alert(selectedIndieces.length + " files have been selected!"); }
onUploadStart()
Description:
Fires when upload begins. Inside handler of this event you can make some additional validations and if, it is demanded, cancel the upload.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onUploadStart() { alert("The upload have been started!"); }
onUploadEnd()
Description:
Fires when upload is successfully completed and a server response is received. You can get the response data from File.serverResponse property.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onUploadEnd() { alert("The upload have been completed!"); }
onUploadCancel()
Description:
Fires when upload is canceled. The upload can be canceled by pressing a "Cancel" button of the user interface or by calling a cancelUpload method.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onUploadCancel() { alert("The upload have been canceled!"); }
onFileLoadStart(fileObj:File)
Parameters:
- fileObj:File - an instance of the File object;
Description:
Fires when a file upload operation starts. This event is dispatched for each uploading file in the upload queue.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onFileLoadStart(fileObj) { alert(fileObj.name + " file is being uploaded."); }
onFileLoadEnd(fileObj:File)
Parameters:
- fileObj:File - an instance of the File object;
Description:
Fires when file is succeessfully uploaded. This event is dispatched for each uploading file in the upload queue.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onFileLoadEnd(fileObj) { alert(fileObj.name + " file has been uploaded."); }
onUploadProgress(progressObj:Progress)
Parameters:
- progressObj:Progress - an instance of Progress object
Description:
Dispatched periodically during the file upload. In some cases, onUploadProgress events are not received. For example, when the file being transmitted is very small or the upload happens very quickly a onUploadProgress event might not be dispatched.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onUploadProgress(progress) { var str = ""; for(var prop in progress) { str += prop + ": " + progress[prop] + "<br />"; } document.getElementById("DIV_ProgressSummary").innerHTML = str; document.getElementById("DIV_ProgressBar").style.width = progress.percentsDone + "%"; }
onUploadError(errorObject:Object)
Parameters:
-
errorObject:Object - an error object with the following properties:
- message:String - an user friendly error message;
- file:File - an instance of the File object;
- systemMessage:String - a system error message;
- type:String - a type of occured error;
Description:
Dispatched if errors occur during upload operation. There are many reasons of error appearance, they are grouped by type:
- HTTP_STATUS_ERROR - an upload fails and an HTTP status code is available to describe the failure
-
IO_ERROR - a file transfer can fail for one of the following reasons:
- An input/output error occurs while the player is reading, writing, or transmitting the file;
- The SWF file tries to upload a file to a server that requires authentication (such as a user name and password). During upload, Flash Player does not provide a means for users to enter passwords. If a SWF file tries to upload a file to a server that requires authentication, the upload fails;
- The value passed to the uploader.uploadUrl property contains an invalid protocol. Valid protocols are HTTP and HTTPS;
- SECURITY_ERROR - the EAFlashUpload tries to upload a file to a server that is outside the security sandbox. The value of the systemMessage property that describes the specific error that occurred is normally "securitySandboxError". The calling SWF file may have tried to access a SWF file outside its domain and does not have permission to do so. You can try to remedy this error by using a URL policy file. See also Web site controls (policy file)
- SERVER_CUSTOM_ERROR - response contain <eaferror></eaferror> tag. "eaferror" tag is created to provide ability to inform EAFlashUpload about server script execution errors. It is much handy way to catch errors instead of return http error codes.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onUploadError(errorObject) { alert("An error occured during upload operation: " + errorObject.message); }
onQueueError(message:String)
Parameters:
- message:String - a message describes an error.
Description:
Fires when adding files are restricted due to some queue limitations. The EAFlashUpload has a number of properties allow to define queue restrictions. They are: filesCountLimit, fileSizeLimit, totalSizeLimit.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onQueueError(message) { alert("A queue error have occured: " + message); }
onSystemError(message:String)
Parameters:
- message:String - a message describes an error.
Description:
Dispatched when various system error occur. This event may be useful on the development stage.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onSystemError(message) { alert(message); }
onAsyncRequestStart()
Description:
Fires when asynchronous request starts. The request is initiated by sendAsyncRequest.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onAsyncRequestStart() { alert("The asynchronous request has been started!"); }
onAsyncRequestEnd(response:Object)
Parameters:
- response:Object - the response data returned from the server.
Description:
Fires when asynchronous request is successfully completed. The response may contain an url variables, so in this case you can convert they to a JavaScript object by using urlVarsToObject method.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onAsyncRequestEnd(response) { alert("The asynchronous request has been completed. the response is: " + response); }
onAsyncRequestError(message:String)
Parameters:
- message:String - a message describes an error.
Description:
Fires when some error occur during asynchronous request.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onAsyncRequestError(message) { alert("An error occured during request: " + message); }
onImageViewResize(width:Number, height:Number)
Parameters:
- width:Number - the actual width of ImageView.
- height:Number - the actual height of ImageView.
Description:
Fires when ImageView is loaded on the page and every time when ImageView sizes are changed dynamically with changing style properties. The size of imagesList depends on the following properties: imagesList.rowCount, imagesList.columnCount, imagesList.cellStyle.maxImageWidth, imagesList.cellStyle.maxImageHeight and is calculated when ImageView is loaded on the page. Therefore to set up the correct size you need to handle onImageViewResize event.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onImageViewResize(width, height) { EAFlashUpload.style.width = width; EAFlashUpload.style.height = height; }
onImagesAdded(imagesIds:Array)
Parameters:
- imagesIds:Array - an array of unique identifiers of added images;
Description:
Fires when preview images are added to imagesList.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onFilesAdded(imagesIds) { var addedImages = EAFlashUpload.getFiles(imagesIds); var someDivElement = document.getElementById("DIV_NamesOfImages"); var imagesNames = ""; for(var i = 0; i < addedImages.length; i++) { imagesNames += addedImages[i].name + "<br />"; } someDivElement.innerHTML = imagesNames; }
onResizedImagesUploadStart()
Description:
Fires when uploading of resized images is started.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onResizedImagesUploadStart() { alert("Resized images uploading has been started!"); }
onResizedImagesUploadEnd()
Description:
Fires when uploading of resized images has been finished.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onResizedImagesUploadEnd() { alert("Resized images are successfully uploaded!"); }
onOriginalImagesUploadStart()
Description:
Fires when uploading of original images begins.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onOriginalImagesUploadStart() { alert("Original images uploading has been started!"); }
onOriginalImagesUploadEnd()
Description:
Fires when uploading of original images is successfully completed.
Examples:
The following example shows how to handle the event on the page:
function EAFlashUpload_onOriginalImagesUploadEnd() { alert("Resized images uploading has been started!"); }