87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovichpackage
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich{
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import com.yahoo.util.YUIBridge;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.display.Loader;
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich import flash.display.DisplayObject;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.display.Sprite;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.display.StageAlign;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.display.StageScaleMode;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.events.DataEvent;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.events.Event;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.events.HTTPStatusEvent;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.events.IOErrorEvent;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.events.KeyboardEvent;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.events.MouseEvent;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.events.ProgressEvent;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.events.SecurityErrorEvent;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.external.ExternalInterface;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.net.FileFilter;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.net.FileReference;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.net.FileReferenceList;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.net.URLRequest;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.net.URLVariables;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.ui.Keyboard;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich import flash.utils.Dictionary;
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich import flash.utils.setTimeout;
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich import flash.filters.GlowFilter;
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich import flash.accessibility.*;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich [SWF(backgroundColor=0xFFFFFF)]
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich /**
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich * The base FlashUploader class for YUI 3.5 FlashUploader.
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich *
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich * @class FlashUploader
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich * @author Allen Rabinovich
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich *
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich */
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich public class FlashUploader extends Sprite {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich /**
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich * Instantiates FlashUploader
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich * @constructor
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich */
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich public function FlashUploader()
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich {
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich fileList = {};
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich filesInProgress = {};
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich singleFile = new FileReference();
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich multipleFiles = new FileReferenceList();
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich yuiBridge = new YUIBridge(this.stage);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich yuiBridge.addCallbacks ({clearFileList:clearFileList, upload:upload,cancel:cancel,setAllowMultipleFiles:setAllowMultipleFiles,setSimUploadLimit:setSimUploadLimit,setFileFilters:setFileFilters,enable:enable, disable:disable});
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich var _accProps:AccessibilityProperties = new AccessibilityProperties();
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich _accProps.silent = false;
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich _accProps.name = "Select Files button";
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich _accProps.description = "Select Files button";
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich this.accessibilityProperties = _accProps;
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich // setTimeout(updateAccessibility, 2000);
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich // this.log("Accactive? " + Accessibility.active);
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich if(Accessibility.active) {
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich Accessibility.updateProperties();
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich }
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.renderAsTransparent();
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich }
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich private function updateAccessibility():void {
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich private function log (msg: String) : void {
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.yuiBridge.sendEvent({type:"trace", message: msg});
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich private function transparentStageResize (evt:Event) : void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich buttonSprite.width = buttonSprite.stage.stageWidth;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich buttonSprite.height = buttonSprite.stage.stageHeight;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich private function keyboardEventHandler (evt : KeyboardEvent) : void {
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich // trace("key received: " + evt.keyCode);
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("Key pressed " + evt.keyCode);
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("Shift key " + evt.shiftKey);
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("Target " + evt.target);
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("In focus: " + this.stage.focus);
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich switch (evt.keyCode) {
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich case 9:
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich if (evt.shiftKey) {
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich // trace("tabback");
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich this.yuiBridge.sendEvent({type:"tabback"});
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich }
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich else {
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich // trace("tabforward");
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich this.yuiBridge.sendEvent({type:"tabforward"});
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich }
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich break;
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich case 32:
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich case 13:
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich if (this.enabled) {
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich this.handleMouseClick(new MouseEvent("mousevent"));
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich }
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich break;
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich }
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich }
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich private function renderAsTransparent () : void {
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich buttonSprite.graphics.beginFill(0xffffff, 0);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich buttonSprite.graphics.drawRect(0,0,5,5);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich buttonSprite.width = this.stage.stageWidth;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich buttonSprite.height = this.stage.stageHeight;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich buttonSprite.graphics.endFill();
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich buttonSprite.tabEnabled = false;
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.stage.scaleMode = StageScaleMode.NO_SCALE;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.stage.align = StageAlign.TOP_LEFT;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.stage.tabChildren = false;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich this.stage.addEventListener(Event.RESIZE, this.transparentStageResize);
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich this.stage.addEventListener(KeyboardEvent.KEY_DOWN, this.keyboardEventHandler);
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich // trace("3.0");
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.buttonMode = true;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.useHandCursor = true;
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.tabEnabled = false;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.enable();
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.addChild(buttonSprite);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich //--------------------------------------------------------------------------
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich //
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich // Variables and setters
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich //
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich //--------------------------------------------------------------------------
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private var buttonSprite:Sprite = new Sprite();
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich private var enabled:Boolean = true;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private var allowMultiple:Boolean = false;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private var filterArray:Array;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private var fileList:Object;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private var filesInProgress:Object;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private var singleFile:FileReference;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private var multipleFiles:FileReferenceList;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private var yuiBridge:YUIBridge;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private var simultaneousUploadLimit:Number = 2;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich public function setSimUploadLimit (simUploadLimit:int) : void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.simultaneousUploadLimit = simUploadLimit;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich public function setFileFilters (filtersArray:Array) : void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich for (var i:int = 0; i < filtersArray.length; i++) {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich filtersArray[i] = new FileFilter(filtersArray[i].description,
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich filtersArray[i].extensions,
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich filtersArray[i].macType);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.filterArray = filtersArray;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich public function setAllowMultipleFiles (allowMultipleFiles:Boolean) : void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.allowMultiple = allowMultipleFiles;
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich //yuiBridge.log("setAllowMultipleFiles has been called, and the allowMultiple value is now " + this.allowMultiple);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich // Browse for single or multiple files, with or without a filter array.
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private function browse (allowMultiple:Boolean = false, filterArray:Array = null):void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich if(!allowMultiple) {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich singleFile = new FileReference();
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich singleFile.addEventListener(Event.SELECT, singleFileSelected);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich if(filterArray) {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich singleFile.browse(filterArray);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich else {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich singleFile.browse();
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich else {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich multipleFiles = new FileReferenceList();
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich multipleFiles.addEventListener(Event.SELECT, multipleFilesSelected);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich if(filterArray) {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich multipleFiles.browse(filterArray);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich else {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich multipleFiles.browse();
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich // Enable or disable the button
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich public function enable () : void {
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich this.enabled = true;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.addEventListener(MouseEvent.CLICK, handleMouseClick);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.addEventListener(MouseEvent.MOUSE_DOWN, handleMouseDown);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.addEventListener(MouseEvent.MOUSE_UP, handleMouseUp);
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich this.stage.addEventListener(MouseEvent.MOUSE_UP, handleMouseUp);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.addEventListener(MouseEvent.ROLL_OVER, handleRollOver);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.addEventListener(MouseEvent.ROLL_OUT, handleRollOut);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich public function disable () : void {
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich this.enabled = false;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.removeEventListener(MouseEvent.CLICK, handleMouseClick);
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.removeEventListener(MouseEvent.MOUSE_DOWN, handleMouseDown);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.removeEventListener(MouseEvent.MOUSE_UP, handleMouseUp);
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich this.stage.removeEventListener(MouseEvent.MOUSE_UP, handleMouseUp);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.removeEventListener(MouseEvent.ROLL_OVER, handleRollOver);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.removeEventListener(MouseEvent.ROLL_OUT, handleRollOut);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich /**
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich * Clears the set of files that had been selected for upload
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich */
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich public function clearFileList():void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.fileList = {};
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich public function upload(fileID:String, url:String, vars:Object = null, fieldName:String = "Filedata"):void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("upload has been called");
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich if(isEmptyString(fieldName)) {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich fieldName = "Filedata";
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("The url is " + url);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var request:URLRequest = formURLRequest(url, "POST", vars);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var file:File = this.fileList[fileID];
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("Got the file with id " + file.fileId);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var fr:FileReference = file.fileReference;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich fr.upload(request, fieldName);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.filesInProgress[fileID] = file;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich public function cancel(fileID:String = null):void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich if (fileID == null) { // cancel all files
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich for each (var item:File in this.filesInProgress) {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich item.fileReference.cancel();
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.filesInProgress = {};
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich else {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var fr:File = filesInProgress[fileID];
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich if (fr) {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich fr.fileReference.cancel();
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich delete filesInProgress[fileID];
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich // Interactive mouse events
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich private function handleMouseClick (evt:*) : void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.browse(this.allowMultiple, this.filterArray);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var newEvent:Object = new Object();
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("mouseclick");
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.type = "click";
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich yuiBridge.sendEvent(newEvent);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private function handleMouseDown (event:MouseEvent) : void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var newEvent:Object = new Object();
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("mousedown");
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.type = "mousedown";
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich yuiBridge.sendEvent(newEvent);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
6a0b5391dbcaace88784e407eb97b46fc8ffb619Allen Rabinovich private function handleMouseUp (event:*) : void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var newEvent:Object = new Object();
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("mouseup");
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.type = "mouseup";
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich yuiBridge.sendEvent(newEvent);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private function handleRollOver (event:MouseEvent) : void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var newEvent:Object = new Object();
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("rollover");
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.type = "mouseenter";
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich yuiBridge.sendEvent(newEvent);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private function handleRollOut (event:MouseEvent) : void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var newEvent:Object = new Object();
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("rollout");
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.type = "mouseleave";
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich yuiBridge.sendEvent(newEvent);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private function uploadStart (event:Event) : void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var newEvent:Object = new Object();
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("START fired for: " + event.target.fileId);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.id = event.target.fileId;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.type = "uploadstart";
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich yuiBridge.sendEvent(newEvent);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private function uploadProgress (event:ProgressEvent) : void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var newEvent:Object = new Object();
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("PROGRESS fired for: " + event.target.fileReference.name + ":::" + event.bytesLoaded + ":::" + event.bytesTotal);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.id = event.target.fileId;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.bytesLoaded = event.bytesLoaded;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.bytesTotal = event.bytesTotal;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.type = "uploadprogress";
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich yuiBridge.sendEvent(newEvent);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private function uploadComplete (event:Event) : void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var newEvent:Object = new Object();
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("COMPLETE fired for: " + event.target.fileId);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.id = event.target.fileId;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.type = "uploadcomplete";
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich yuiBridge.sendEvent(newEvent);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private function uploadCompleteData (event:DataEvent) : void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var newEvent:Object = new Object();
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("COMPLETEDATA fired for: " + event.target.fileId);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.id = event.target.fileId;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.data = event.data;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.type = "uploadcompletedata";
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich yuiBridge.sendEvent(newEvent);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private function uploadCancel (event:Event) : void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var newEvent:Object = new Object();
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("CANCEL fired for: " + event.target.fileId);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.id = event.target.fileId;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.type = "uploadcancel";
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich yuiBridge.sendEvent(newEvent);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private function uploadError (event:Event) : void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var newEvent:Object = new Object();
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("ERROR has fired for: " + event.target.fileId);
a9a4fee30864f00049b02201b1af50ada7f769e3Allen Rabinovich this.log("The event type is " + event.type);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich if (event is IOErrorEvent) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich this.log("The event text is " + (event as IOErrorEvent).text);
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich newEvent.source="io";
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich newEvent.message = (event as IOErrorEvent).text;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich else if (event is HTTPStatusEvent) {
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich this.log("The event status is " + (event as HTTPStatusEvent).status);
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich newEvent.source="http";
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich newEvent.message = (event as HTTPStatusEvent).status;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich for (var itemName:String in event) {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent[itemName] = event[itemName];
ec749fdeacb8e11cb7a9dd6dcebd1538b953059eAllen Rabinovich this.log("Error details / " + itemName + ": " + event[itemName]);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.id = event.target.fileId;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich yuiBridge.sendEvent(newEvent);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich // Fired when the user selects a single file
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private function singleFileSelected(event:Event):void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich this.clearFileList();
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var newFile:File = addFile(event.target as FileReference);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich processSelection(new Array(newFile));
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich // Fired when the user selects multiple files
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private function multipleFilesSelected(event:Event):void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var currentFRL:FileReferenceList = event.target as FileReferenceList;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var addedFiles:Array = [];
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich for each (var currentFR:FileReference in currentFRL.fileList) {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich addedFiles.push(addFile(currentFR));
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich processSelection(addedFiles);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich /**
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich * @private
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich * Outputs the files selected to an output panel and triggers a 'fileSelect' event.
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich */
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private function processSelection(selectedFiles : Array):void {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var newEvent:Object = new Object();
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.fileList = selectedFiles;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newEvent.type = "fileselect";
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich yuiBridge.sendEvent(newEvent);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich /**
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich * @private
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich * Adds a file reference object to the internal queue and assigns listeners to its events
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich */
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private function addFile(fr:FileReference) : File {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var newFile:File = new File(fr);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newFile.addEventListener(Event.OPEN, uploadStart);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newFile.addEventListener(ProgressEvent.PROGRESS, uploadProgress);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newFile.addEventListener(Event.COMPLETE, uploadComplete);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newFile.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, uploadCompleteData);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newFile.addEventListener(HTTPStatusEvent.HTTP_STATUS, uploadError);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newFile.addEventListener(IOErrorEvent.IO_ERROR, uploadError);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newFile.addEventListener(SecurityErrorEvent.SECURITY_ERROR, uploadError);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich newFile.addEventListener(Event.CANCEL,uploadCancel);
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich fileList[newFile.fileId] = newFile;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich return newFile;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich /**
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich * @private
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich * Creates a URLRequest object from a url, and optionally includes an HTTP request method and additional variables to be sent
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich */
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private function formURLRequest(url:String, method:String = "GET", vars:Object = null):URLRequest {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich var request:URLRequest = new URLRequest();
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich request.url = url;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich request.method = method;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich request.data = new URLVariables();
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich for (var itemName:String in vars) {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich request.data[itemName] = vars[itemName];
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich return request;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich /**
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich * @private
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich * Determines whether an object is equivalent to an empty string
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich */
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich private function isEmptyString(toCheck:*):Boolean {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich if( toCheck == "null" ||
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich toCheck == "" ||
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich toCheck == null ) {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich return true;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich else {
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich return false;
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich }
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich}
87fff29257e74dac31f23eac9e31c028a551057fAllen Rabinovich