first import
This commit is contained in:
121
sites/all/libraries/swfupload/Flash/ExternalCall.as
Normal file
121
sites/all/libraries/swfupload/Flash/ExternalCall.as
Normal file
@@ -0,0 +1,121 @@
|
||||
package {
|
||||
import flash.external.ExternalInterface;
|
||||
|
||||
internal class ExternalCall
|
||||
{
|
||||
|
||||
/*public function ExternalCall()
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
public static function Simple(callback:String):void {
|
||||
ExternalInterface.call(callback);
|
||||
}
|
||||
public static function FileQueued(callback:String, file_object:Object):void {
|
||||
ExternalInterface.call(callback, EscapeMessage(file_object));
|
||||
}
|
||||
public static function FileQueueError(callback:String, error_code:Number, file_object:Object, message:String):void {
|
||||
|
||||
ExternalInterface.call(callback, EscapeMessage(file_object), EscapeMessage(error_code), EscapeMessage(message));
|
||||
|
||||
}
|
||||
public static function FileDialogComplete(callback:String, num_files_selected:Number, num_files_queued:Number, total_num_files_queued:Number):void {
|
||||
|
||||
ExternalInterface.call(callback, EscapeMessage(num_files_selected), EscapeMessage(num_files_queued), EscapeMessage(total_num_files_queued));
|
||||
|
||||
}
|
||||
|
||||
public static function UploadStart(callback:String, file_object:Object):void {
|
||||
ExternalInterface.call(callback, EscapeMessage(file_object));
|
||||
}
|
||||
|
||||
public static function UploadProgress(callback:String, file_object:Object, bytes_loaded:uint, bytes_total:uint):void {
|
||||
|
||||
ExternalInterface.call(callback, EscapeMessage(file_object), EscapeMessage(bytes_loaded), EscapeMessage(bytes_total));
|
||||
|
||||
}
|
||||
public static function UploadSuccess(callback:String, file_object:Object, server_data:String, responseReceived:Boolean):void {
|
||||
|
||||
ExternalInterface.call(callback, EscapeMessage(file_object), EscapeMessage(server_data), EscapeMessage(responseReceived));
|
||||
|
||||
}
|
||||
public static function UploadError(callback:String, error_code:Number, file_object:Object, message:String):void {
|
||||
|
||||
ExternalInterface.call(callback, EscapeMessage(file_object), EscapeMessage(error_code), EscapeMessage(message));
|
||||
|
||||
}
|
||||
public static function UploadComplete(callback:String, file_object:Object):void {
|
||||
|
||||
ExternalInterface.call(callback, EscapeMessage(file_object));
|
||||
|
||||
}
|
||||
public static function Debug(callback:String, message:String):void {
|
||||
|
||||
ExternalInterface.call(callback, EscapeMessage(message));
|
||||
}
|
||||
|
||||
public static function Bool(callback:String):Boolean {
|
||||
return ExternalInterface.call(callback);
|
||||
}
|
||||
|
||||
|
||||
/* Escapes all the backslashes which are not translated correctly in the Flash -> JavaScript Interface
|
||||
*
|
||||
* These functions had to be developed because the ExternalInterface has a bug that simply places the
|
||||
* value a string in quotes (except for a " which is escaped) in a JavaScript string literal which
|
||||
* is executed by the browser. These often results in improperly escaped string literals if your
|
||||
* input string has any backslash characters. For example the string:
|
||||
* "c:\Program Files\uploadtools\"
|
||||
* is placed in a string literal (with quotes escaped) and becomes:
|
||||
* var __flash__temp = "\"c:\Program Files\uploadtools\\"";
|
||||
* This statement will cause errors when executed by the JavaScript interpreter:
|
||||
* 1) The first \" is succesfully transformed to a "
|
||||
* 2) \P is translated to P and the \ is lost
|
||||
* 3) \u is interpreted as a unicode character and causes an error in IE
|
||||
* 4) \\ is translated to \
|
||||
* 5) leaving an unescaped " which causes an error
|
||||
*
|
||||
* I fixed this by escaping \ characters in all outgoing strings. The above escaped string becomes:
|
||||
* var __flash__temp = "\"c:\\Program Files\\uploadtools\\\"";
|
||||
* which contains the correct string literal.
|
||||
*
|
||||
* Note: The "var __flash__temp = " portion of the example is part of the ExternalInterface not part of
|
||||
* my escaping routine.
|
||||
*/
|
||||
private static function EscapeMessage(message:*):* {
|
||||
if (message is String) {
|
||||
message = EscapeString(message);
|
||||
}
|
||||
else if (message is Array) {
|
||||
message = EscapeArray(message);
|
||||
}
|
||||
else if (message is Object) {
|
||||
message = EscapeObject(message);
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
private static function EscapeString(message:String):String {
|
||||
var replacePattern:RegExp = /\\/g; //new RegExp("/\\/", "g");
|
||||
return message.replace(replacePattern, "\\\\");
|
||||
}
|
||||
private static function EscapeArray(message_array:Array):Array {
|
||||
var length:uint = message_array.length;
|
||||
var i:uint = 0;
|
||||
for (i; i < length; i++) {
|
||||
message_array[i] = EscapeMessage(message_array[i]);
|
||||
}
|
||||
return message_array;
|
||||
}
|
||||
private static function EscapeObject(message_obj:Object):Object {
|
||||
for (var name:String in message_obj) {
|
||||
message_obj[name] = EscapeMessage(message_obj[name]);
|
||||
}
|
||||
return message_obj;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
112
sites/all/libraries/swfupload/Flash/FileItem.as
Normal file
112
sites/all/libraries/swfupload/Flash/FileItem.as
Normal file
@@ -0,0 +1,112 @@
|
||||
package {
|
||||
import flash.net.FileReference;
|
||||
|
||||
internal class FileItem
|
||||
{
|
||||
private static var file_id_sequence:Number = 0; // tracks the file id sequence
|
||||
|
||||
private var postObject:Object;
|
||||
public var file_reference:FileReference;
|
||||
public var id:String;
|
||||
public var index:Number = -1;
|
||||
public var file_status:int = 0;
|
||||
private var js_object:Object;
|
||||
|
||||
public static var FILE_STATUS_QUEUED:int = -1;
|
||||
public static var FILE_STATUS_IN_PROGRESS:int = -2;
|
||||
public static var FILE_STATUS_ERROR:int = -3;
|
||||
public static var FILE_STATUS_SUCCESS:int = -4;
|
||||
public static var FILE_STATUS_CANCELLED:int = -5;
|
||||
public static var FILE_STATUS_NEW:int = -6; // This file status should never be sent to JavaScript
|
||||
|
||||
public function FileItem(file_reference:FileReference, control_id:String, index:Number)
|
||||
{
|
||||
this.postObject = {};
|
||||
this.file_reference = file_reference;
|
||||
this.id = control_id + "_" + (FileItem.file_id_sequence++);
|
||||
this.file_status = FileItem.FILE_STATUS_NEW;
|
||||
this.index = index;
|
||||
|
||||
this.js_object = {
|
||||
id: this.id,
|
||||
index: this.index,
|
||||
post: this.GetPostObject()
|
||||
};
|
||||
|
||||
// Cleanly attempt to retrieve the FileReference info
|
||||
// this can fail and so is wrapped in try..catch
|
||||
try {
|
||||
this.js_object.name = this.file_reference.name;
|
||||
this.js_object.size = this.file_reference.size;
|
||||
this.js_object.type = this.file_reference.type || "";
|
||||
this.js_object.creationdate = this.file_reference.creationDate || new Date(0);
|
||||
this.js_object.modificationdate = this.file_reference.modificationDate || new Date(0);
|
||||
} catch (ex:Error) {
|
||||
this.file_status = FileItem.FILE_STATUS_ERROR;
|
||||
}
|
||||
|
||||
this.js_object.filestatus = this.file_status;
|
||||
}
|
||||
|
||||
public function AddParam(name:String, value:String):void {
|
||||
this.postObject[name] = value;
|
||||
}
|
||||
|
||||
public function RemoveParam(name:String):void {
|
||||
delete this.postObject[name];
|
||||
}
|
||||
|
||||
public function GetPostObject(escape:Boolean = false):Object {
|
||||
if (escape) {
|
||||
var escapedPostObject:Object = { };
|
||||
for (var k:String in this.postObject) {
|
||||
if (this.postObject.hasOwnProperty(k)) {
|
||||
var escapedName:String = FileItem.EscapeParamName(k);
|
||||
escapedPostObject[escapedName] = this.postObject[k];
|
||||
}
|
||||
}
|
||||
return escapedPostObject;
|
||||
} else {
|
||||
return this.postObject;
|
||||
}
|
||||
}
|
||||
|
||||
// Create the simply file object that is passed to the browser
|
||||
public function ToJavaScriptObject():Object {
|
||||
this.js_object.filestatus = this.file_status;
|
||||
this.js_object.post = this.GetPostObject(true);
|
||||
|
||||
return this.js_object;
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
return "FileItem - ID: " + this.id;
|
||||
}
|
||||
|
||||
/*
|
||||
// The purpose of this function is to escape the property names so when Flash
|
||||
// passes them back to javascript they can be interpretted correctly.
|
||||
// ***They have to be unescaped again by JavaScript.**
|
||||
//
|
||||
// This works around a bug where Flash sends objects this way:
|
||||
// object.parametername = "value";
|
||||
// instead of
|
||||
// object["parametername"] = "value";
|
||||
// This can be a problem if the parameter name has characters that are not
|
||||
// allowed in JavaScript identifiers:
|
||||
// object.parameter.name! = "value";
|
||||
// does not work but,
|
||||
// object["parameter.name!"] = "value";
|
||||
// would have worked.
|
||||
*/
|
||||
public static function EscapeParamName(name:String):String {
|
||||
name = name.replace(/[^a-z0-9_]/gi, FileItem.EscapeCharacter);
|
||||
name = name.replace(/^[0-9]/, FileItem.EscapeCharacter);
|
||||
return name;
|
||||
}
|
||||
public static function EscapeCharacter():String {
|
||||
return "$" + ("0000" + arguments[0].charCodeAt(0).toString(16)).substr(-4, 4);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
79
sites/all/libraries/swfupload/Flash/SWFUpload v2.as3proj
Normal file
79
sites/all/libraries/swfupload/Flash/SWFUpload v2.as3proj
Normal file
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<!-- Output SWF options -->
|
||||
<output>
|
||||
<movie disabled="False" />
|
||||
<movie input="" />
|
||||
<movie path="swfupload.swf" />
|
||||
<movie fps="15" />
|
||||
<movie width="300" />
|
||||
<movie height="300" />
|
||||
<movie version="9" />
|
||||
<movie background="#FFFFFF" />
|
||||
</output>
|
||||
<!-- Other classes to be compiled into your SWF -->
|
||||
<classpaths>
|
||||
<class path="." />
|
||||
</classpaths>
|
||||
<!-- Build options -->
|
||||
<build>
|
||||
<option accessible="False" />
|
||||
<option allowSourcePathOverlap="False" />
|
||||
<option benchmark="False" />
|
||||
<option es="False" />
|
||||
<option loadConfig="" />
|
||||
<option optimize="True" />
|
||||
<option showActionScriptWarnings="True" />
|
||||
<option showBindingWarnings="True" />
|
||||
<option showDeprecationWarnings="True" />
|
||||
<option showUnusedTypeSelectorWarnings="True" />
|
||||
<option strict="True" />
|
||||
<option useNetwork="True" />
|
||||
<option useResourceBundleMetadata="True" />
|
||||
<option warnings="True" />
|
||||
<option verboseStackTraces="False" />
|
||||
<option additional="" />
|
||||
<option customSDK="" />
|
||||
</build>
|
||||
<!-- SWC Include Libraries -->
|
||||
<includeLibraries>
|
||||
<!-- example: <element path="..." /> -->
|
||||
</includeLibraries>
|
||||
<!-- SWC Libraries -->
|
||||
<libraryPaths>
|
||||
<!-- example: <element path="..." /> -->
|
||||
</libraryPaths>
|
||||
<!-- External Libraries -->
|
||||
<externalLibraryPaths>
|
||||
<!-- example: <element path="..." /> -->
|
||||
</externalLibraryPaths>
|
||||
<!-- Runtime Shared Libraries -->
|
||||
<rslPaths>
|
||||
<!-- example: <element path="..." /> -->
|
||||
</rslPaths>
|
||||
<!-- Intrinsic Libraries -->
|
||||
<intrinsics>
|
||||
<!-- example: <element path="..." /> -->
|
||||
</intrinsics>
|
||||
<!-- Assets to embed into the output SWF -->
|
||||
<library>
|
||||
<!-- example: <asset path="..." id="..." update="..." glyphs="..." mode="..." place="..." sharepoint="..." /> -->
|
||||
</library>
|
||||
<!-- Class files to compile (other referenced classes will automatically be included) -->
|
||||
<compileTargets>
|
||||
<compile path="SWFUpload.as" />
|
||||
</compileTargets>
|
||||
<!-- Paths to exclude from the Project Explorer tree -->
|
||||
<hiddenPaths>
|
||||
<!-- example: <hidden path="..." /> -->
|
||||
</hiddenPaths>
|
||||
<!-- Executed before build -->
|
||||
<preBuildCommand />
|
||||
<!-- Executed after build -->
|
||||
<postBuildCommand alwaysRun="True">deploy.bat</postBuildCommand>
|
||||
<!-- Other project options -->
|
||||
<options>
|
||||
<option showHiddenPaths="False" />
|
||||
<option testMovie="NewWindow" />
|
||||
</options>
|
||||
</project>
|
1519
sites/all/libraries/swfupload/Flash/SWFUpload.as
Normal file
1519
sites/all/libraries/swfupload/Flash/SWFUpload.as
Normal file
File diff suppressed because it is too large
Load Diff
3
sites/all/libraries/swfupload/Flash/deploy.bat
Normal file
3
sites/all/libraries/swfupload/Flash/deploy.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
copy ..\swfupload.js ..\..\samples\demos\swfupload
|
||||
copy swfupload.swf ..\..\samples\demos\swfupload
|
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Flex compiler config for project SWFUpload-v2 generated by FDBuild-->
|
||||
<!--============-->
|
||||
<!--This file was generated by a tool.-->
|
||||
<!--Any modifications you make may be lost.-->
|
||||
<flex-config>
|
||||
<compiler>
|
||||
<source-path append="true">
|
||||
<path-element>C:\inetpub\wwwroot\other\swfupload\core\Flash</path-element>
|
||||
<path-element>C:\Program Files (x86)\FlashDevelop\Library\AS3\classes</path-element>
|
||||
</source-path>
|
||||
</compiler>
|
||||
<file-specs>
|
||||
<path-element>C:\inetpub\wwwroot\other\swfupload\core\Flash\SWFUpload.as</path-element>
|
||||
</file-specs>
|
||||
<default-background-color>#FFFFFF</default-background-color>
|
||||
<default-frame-rate>15</default-frame-rate>
|
||||
<default-size>
|
||||
<width>300</width>
|
||||
<height>300</height>
|
||||
</default-size>
|
||||
</flex-config>
|
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--Flex compiler config for project SWFUpload-v2 generated by FDBuild-->
|
||||
<!--============-->
|
||||
<!--This file was generated by a tool.-->
|
||||
<!--Any modifications you make may be lost.-->
|
||||
<flex-config>
|
||||
<compiler>
|
||||
<source-path append="true">
|
||||
<path-element>C:\inetpub\wwwroot\other\swfupload\core\Flash</path-element>
|
||||
<path-element>C:\Program Files (x86)\FlashDevelop\Library\AS3\classes</path-element>
|
||||
</source-path>
|
||||
</compiler>
|
||||
<file-specs>
|
||||
<path-element>C:\inetpub\wwwroot\other\swfupload\core\Flash\SWFUpload.as</path-element>
|
||||
</file-specs>
|
||||
<default-background-color>#FFFFFF</default-background-color>
|
||||
<default-frame-rate>15</default-frame-rate>
|
||||
<default-size>
|
||||
<width>300</width>
|
||||
<height>300</height>
|
||||
</default-size>
|
||||
</flex-config>
|
BIN
sites/all/libraries/swfupload/Flash/swfupload.swf
Normal file
BIN
sites/all/libraries/swfupload/Flash/swfupload.swf
Normal file
Binary file not shown.
Reference in New Issue
Block a user