Frame 1
com.mammon.swfupload.SWFUpload.main(this);
Symbol 20480 MovieClip [__Packages.com.mammon.swfupload.SWFUpload] Frame 0
class com.mammon.swfupload.SWFUpload
{
var allowedFiletypes, allowedFiletypesDescription, maximumFilesize, uploadScript, uploadFileCancelCallback, uploadDialogCancelCallback, uploadFileCompleteCallback, uploadFileErrorCallback, uploadFileQueuedCallback, uploadProgressCallback, uploadQueueCompleteCallback, flashLoadedCallback, uploadFileStartCallback;
function SWFUpload () {
allowedFiletypes = _root.allowedFiletypes;
allowedFiletypesDescription = _root.allowedFiletypesDescription;
autoUpload = _root.autoUpload;
maximumFilesize = _root.maximumFilesize;
uploadScript = _root.uploadScript;
uploadFileCancelCallback = _root.uploadFileCancelCallback;
uploadDialogCancelCallback = _root.uploadDialogCancelCallback;
uploadFileCompleteCallback = _root.uploadFileCompleteCallback;
uploadFileErrorCallback = _root.uploadFileErrorCallback;
uploadFileQueuedCallback = _root.uploadFileQueuedCallback;
uploadProgressCallback = _root.uploadProgressCallback;
uploadQueueCompleteCallback = _root.uploadQueueCompleteCallback;
flashLoadedCallback = _root.flashLoadedCallback;
uploadFileStartCallback = _root.uploadFileStartCallback;
System.security.allowDomain("*");
listener.onCancel = com.mammon.swfupload.Delegate.create(this, uploadCancel);
listener.onComplete = com.mammon.swfupload.Delegate.create(this, uploadComplete);
listener.onProgress = com.mammon.swfupload.Delegate.create(this, uploadProgress);
listener.onHTTPError = com.mammon.swfupload.Delegate.create(this, uploadHTTPError);
listener.onIOError = com.mammon.swfupload.Delegate.create(this, uploadIOError);
listener.onSecurityError = com.mammon.swfupload.Delegate.create(this, uploadSecurityError);
listener.onSelect = com.mammon.swfupload.Delegate.create(this, uploadSelect);
fileList.addListener(listener);
flash.external.ExternalInterface.addCallback("browse", this, browse);
flash.external.ExternalInterface.addCallback("upload", this, upload);
flash.external.ExternalInterface.addCallback("cancelFile", this, cancelFile);
flash.external.ExternalInterface.addCallback("cancelQueue", this, cancelQueue);
if (flashLoadedCallback.length > 0) {
flash.external.ExternalInterface.call(flashLoadedCallback, true);
}
}
static function main() {
var _local2 = new com.mammon.swfupload.SWFUpload();
}
function browse() {
fileList.browse([{description:allowedFiletypesDescription, extension:allowedFiletypes}]);
}
function cancelFile(id) {
var _local3 = id.split("_", 2)[1];
var _local4 = flash.net.FileReference(fileQueue[_local3]);
if (_local4) {
_local4.cancel();
delete fileQueue[_local3];
fileQueueLength--;
if (uploadFileCancelCallback.length > 0) {
flash.external.ExternalInterface.call(uploadFileCancelCallback, getFileObject(_local3, _local4), fileQueueLength);
}
}
}
function cancelQueue() {
var _local2 = null;
var _local3 = currentFileId;
for ( ; _local3 < fileQueue.length ; _local3++) {
_local2 = flash.net.FileReference(fileQueue[_local3]);
if (_local2) {
_local2.cancel();
delete fileQueue[_local3];
fileQueueLength--;
if (uploadFileCancelCallback.length > 0) {
flash.external.ExternalInterface.call(uploadFileCancelCallback, getFileObject(_local3, _local2), fileQueueLength);
}
}
}
fileQueueLength = 0;
if (uploadQueueCompleteCallback.length > 0) {
flash.external.ExternalInterface.call(uploadQueueCompleteCallback);
}
}
function upload() {
var _local2 = null;
while ((!_local2) && ((fileQueue.length - 1) >= currentFileId)) {
_local2 = flash.net.FileReference(fileQueue[currentFileId]);
if (!_local2) {
delete fileQueue[currentFileId];
currentFileId++;
}
}
if (_local2) {
position++;
if (uploadFileStartCallback.length > 0) {
flash.external.ExternalInterface.call(uploadFileStartCallback, getFileObject(currentFileId, _local2), position, fileQueueLength);
}
_local2.addListener(listener);
_local2.upload(uploadScript);
} else if (uploadQueueCompleteCallback.length > 0) {
flash.external.ExternalInterface.call(uploadQueueCompleteCallback);
}
}
function uploadCancel() {
if (uploadDialogCancelCallback.length > 0) {
flash.external.ExternalInterface.call(uploadDialogCancelCallback);
}
}
function uploadComplete(file) {
if (uploadFileCompleteCallback.length > 0) {
flash.external.ExternalInterface.call(uploadFileCompleteCallback, getFileObject(currentFileId, file));
}
fileComplete();
}
function uploadHTTPError(file, httpError) {
flash.external.ExternalInterface.call(uploadFileErrorCallback, -10, getFileObject(currentFileId, file), httpError);
fileComplete();
}
function uploadIOError(file) {
if (uploadScript.length > 0) {
flash.external.ExternalInterface.call(uploadFileErrorCallback, -30, getFileObject(currentFileId, file));
} else {
flash.external.ExternalInterface.call(uploadFileErrorCallback, -20, getFileObject(currentFileId, file), "No backend file specified");
}
fileComplete();
}
function uploadProgress(file, bytesLoaded, bytesTotal) {
if (uploadProgressCallback.length > 0) {
flash.external.ExternalInterface.call(uploadProgressCallback, getFileObject(currentFileId, file), bytesLoaded, bytesTotal);
}
}
function uploadSecurityError(file, errorString) {
flash.external.ExternalInterface.call(uploadFileErrorCallback, -40, getFileObject(currentFileId, file));
fileComplete();
}
function uploadSelect(fileRefList) {
var _local3 = fileRefList.fileList;
var _local5 = 0;
for ( ; _local5 < _local3.length ; _local5++) {
var _local4 = _local3[_local5];
if (checkFileSize(_local4)) {
fileQueue.push(_local4);
fileQueueLength++;
if (uploadFileQueuedCallback.length > 0) {
flash.external.ExternalInterface.call(uploadFileQueuedCallback, getFileObject(fileQueue.length - 1, _local4), fileQueueLength);
}
} else {
flash.external.ExternalInterface.call(uploadFileErrorCallback, -50, getFileObject(fileQueue.length - 1, _local4), "Filesize exceeds allowed limit.");
}
}
if (autoUpload == "true") {
upload();
}
}
function fileComplete() {
delete fileQueue[currentFileId];
currentFileId++;
upload();
}
function getFileObject(id, file) {
return({id:(controlId.toString() + "_") + id.toString(), name:file.name, size:file.size, type:file.type, creationDate:file.creationDate, creator:file.creator});
}
function checkFileSize(file) {
return(((maximumFilesize > 0) ? (file.size < (maximumFilesize * 1024)) : true));
}
var controlId = Math.floor(Math.random() * 10000) + 1;
var currentFile = null;
var currentFileId = 0;
var fileList = new flash.net.FileReferenceList();
var fileQueue = new Array();
var intervalId = null;
var listener = new Object();
var fileQueueLength = 0;
var position = 0;
var autoUpload = false;
}
Symbol 20481 MovieClip [__Packages.com.mammon.swfupload.Delegate] Frame 0
class com.mammon.swfupload.Delegate
{
function Delegate () {
}
static function create(obj, func) {
return(function () {
return(func.apply(obj, arguments));
});
}
}