Wednesday, September 19, 2007

SWFUpload Revision 7.0 Beta

I have almost completed work on Revision 7.0. I think the coding on the SWF and JS files is done. But I have not had time to convert the demos. I decided to post a "Beta" since I don't know when I'll have time to come back to the demos and documentation.

The R7 beta will be available at http://swfupload.praxion.co.za/

R7 Notes

The API has change significantly for R7 (that's why is R7 and not R65). You won't be able to drop this in over SWFUpload v1.0.2 or any of the other Revisions.

This version uses a different event model which introduced some issues with the Flash to JavaScript and JavaScript to Flash calls. I think I've resolved them but I'm sure someone will figure out a way to bring the bug up again. The long of the short of it is that when Flash calls to JavaScript if that JavaScript thread calls back in to Flash then Flash misbehaves. In order to work around this I use a setTimeout (the Timer class in ActionScript) to make calls from Flash to JavaScript. This effectively makes the call on a separate thread and works around the problem. The only place that this is not done is the call to the uploadStart event since uploadStart is required to return true or false. If you make any calls in to the Flash from uploadStart then you run the risk of triggering this issue.

Several pieces of functionality will appear to have been removed from this version. Almost everything that has been removed is still doable using the new events. There are comments in the code that explain some things and once the demos are complete hopefully you will be able to see how everything works.


Changes
  • Removed the settings: begin_upload_on_queue, validate_files, and use_server_data_event.
  • Changed the setting: upload_target_url to upload_url.
  • The events called are as follows and are listed in their approximate order:
    • fileDialogStart: Called from Flash immediately before the File Dialog is displayed.
    • fileQueued: Called once for each file that is added to the queue.
    • fileQueueError: Called once for each file that fails to be added to the queue.
    • fileDialogComplete: Called after all selected files have been processed.
    • uploadStart: Called for each file in the queue immediately before it is uploaded. Return true to continue the upload. Return false to skip the upload.
    • uploadProgress: Called periodically to provide upload status for the current file.
    • uploadError: Called when an error occurs on an upload or if an upload is cancelled.
    • uploadComplete: Called when an upload finishes successfully.
    • fileComplete: Called after an upload and SWFUpload is ready to allow another upload to begin. This is called even if an upload is cancelled or has an error.
  • Removed the queueComplete event and the cancelQueue command.
  • Enhanced the cancelUpload command so if it is not passed a File ID then the current upload or first file in the queue is cancelled.
  • File cancelling behavior has changed. If an in-progress upload is cancelled the uploadError event is fired and the fileComplete event is fired. If the file is not currently uploading then only the uploadError event is called.
  • Added a GetStats command. This returns an object that contains the number of successful uploads, the number of files remaining in the queue (excluding the current upload, if any), the number of queue errors and the number of upload errors.
  • Added a file_status property to the File Object.
  • Added a single file browser. This allows the user to only select a single file for upload.
Some of the Command names, Event names, and Error code constants have changed. See the source code for the updated names.