Packageardisia.components.htmlDragDrop
Classpublic class HtmlDragDrop
InheritanceHtmlDragDrop Inheritance HtmlFrame Inheritance spark.components.supportClasses.SkinnableComponent

Supports drag and drop of files from the user's desktop to the Flex app via the HTML5 drag and drop API. Currently supported in recent versions of Firefox, Chrome, and IE.

This component will NOT work within the AIR environment. For HTML support in AIR, try the native mx.controls.HTML and flash.html.HTMLLoader classes.

This component can accept multiple dropped files. When multiple files are dropped together, the "dragLoad" event will fire for each file dropped. Drops can be cancelled via the "dragDropStarting" event.

See the HtmlDragDropFile and HtmlDragDropEvent classes for the information available to the flex app during dragging and dropping.

View the technical documentation on the Ardisia Labs website for more information.

DESIGN NOTES



Public Properties
 PropertyDefined By
 InheritedframeId : String
[read-only] The html DOM id of the frame.
HtmlFrame
 InheritedframePaddingBottom : Number
Padding used to inset the frame.
HtmlFrame
 InheritedframePaddingLeft : Number
Padding used to inset the frame.
HtmlFrame
 InheritedframePaddingRight : Number
Padding used to inset the frame.
HtmlFrame
 InheritedframePaddingTop : Number
Padding used to inset the frame.
HtmlFrame
  isDraggedOver : Boolean
[read-only] Return whether the user is dragging over the control via the HTML5 api.
HtmlDragDrop
  isDropping : Boolean
[read-only] Return whether a drag is being processed.
HtmlDragDrop
  isSupported : Boolean
[read-only] Return whether the ExternalInterface supports the HTML5 drag and drop API.
HtmlDragDrop
 InheritedsourceURL : String
[read-only] Return the value of the "src" property on the frame, if any.
HtmlFrame
 Inheritedvisible : Boolean
[override] Sets the visibility of the component for both the underlying Group and the html frame.
HtmlFrame
Protected Properties
 PropertyDefined By
 Inherited_borderThickness : Number = 1
HtmlFrame
 Inherited_borderVisible : Boolean = true
HtmlFrame
 InheritedCHECK_TEST_ID_CALLBACK : String = checkTestIdCallback
HtmlFrame
 InheritedONLOAD_CALLBACK : String = onloadCallback
HtmlFrame
 InheritedRESIZE_CALLBACK : String = resizeCallback
HtmlFrame
 InheritedstylesDirty : Boolean
HtmlFrame
Public Methods
 MethodDefined By
 Inherited
callFrameFunction(functionName:String, params:Array = null):*
Call the named function on the frame.
HtmlFrame
 Inherited
dispose():void
Completely remove the frame and flex container.
HtmlFrame
 Inherited
printFrame():void
Print the frame.
HtmlFrame
 Inherited
setFrameRawHTML(markup:String):void
Set the raw html markup for the html frame to the passed string.
HtmlFrame
 Inherited
setFrameSourceURL(url:String):void
Set the "src" property on the html frame.
HtmlFrame
 Inherited
setStyleProperty(propertyName:String, value:String):void
Set a style property on the frame.
HtmlFrame
Protected Methods
 MethodDefined By
 Inherited
Add the functions that the browser can call via javascript.
HtmlFrame
 Inherited
Sets up and calls javascript code to store a reference to the embedded swf on the browser window object.
HtmlFrame
 Inherited
Call all the queued functions and reset the queue.
HtmlFrame
 Inherited
Create the html frame.
HtmlFrame
  
dragDropErrorHandler(frameId:String, error:String, file:Object):void
Handles error events returned by javascript.
HtmlDragDrop
  
dragHandler(frameId:String, type:String, dataTransfer:Object, types:Array):Array
Handles the drag events.
HtmlDragDrop
  
dropHandler(frameId:String, type:String, file:Object = null, data:* = null, progress:Object = null):Boolean
Handles drop events.
HtmlDragDrop
 Inherited
eventHandler(event:Event):void
Handles events for the class.
HtmlFrame
 Inherited
frameHandler(frameId:String):void
[static] Called by javascript code after a html frame fires the 'onload' event.
HtmlFrame
 Inherited
isTestId(testString:String):Boolean
Called by the browser in javascript.
HtmlFrame
 Inherited
Layout the frame.
HtmlFrame
 Inherited
Remove the iframe.
HtmlFrame
 Inherited
[static] Called by javascript code after the html frame window fires its 'resize' event.
HtmlFrame
Events
 Event Summary Defined By
  Dispatched when the dropped file was being read into a data buffer, but was aborted.HtmlDragDrop
  Dispatched when the browser does not support file drag and drop.HtmlDragDrop
  Dispatched immediately after a drop is initiated over the control.HtmlDragDrop
  Dispatched when the user drags over the control.HtmlDragDrop
  Dispatched when the user drags out of the control.HtmlDragDrop
  Dispatched when a dropped file has been fully processed by both javascript and actionscript and is available as a ByteArray.HtmlDragDrop
  Dispatched when a drop file is initially being read into memory.HtmlDragDrop
  Dispatched continuously when the user is dragging over the control.HtmlDragDrop
  Dispatched while the dropped file is being read into a buffer by the browser.HtmlDragDrop
 InheritedDispatched when the "onload" event is dispatched by the html frame.HtmlFrame
  Dispatched when the dropped file was not found.HtmlDragDrop
  Dispatched when the dropped file was not readable by the browser.HtmlDragDrop
  Dispatched when the error was unknown.HtmlDragDrop
Styles
 Style Description Defined By
 InheritedType: Number CSS Inheritance: no
The alpha of the background.
HtmlFrame
 InheritedType: uint Format: Color CSS Inheritance: no
The color of the background.
HtmlFrame
 InheritedType: Number CSS Inheritance: no
The alpha of the border.
HtmlFrame
 InheritedType: uint Format: Color CSS Inheritance: no
The color of the border.
HtmlFrame
 InheritedType: Number CSS Inheritance: no
The thickness of the border.
HtmlFrame
 InheritedType: Boolean CSS Inheritance: no
Whether to display a border.
HtmlFrame
Skin States

To skin the component, implement a skin that defines the following states. Although you must implement all skin states, a skin state can be empty. An empty skin state specifies no changes to the default skin state.


 Skin State Description Defined By
 InheritedHtmlFrame
 Inherited State after the start of loading content into the html frame, but before the "onload" event fires on the html iframe. HtmlFrame
 InheritedHtmlFrame
Property Detail
isDraggedOverproperty
isDraggedOver:Boolean  [read-only]

Return whether the user is dragging over the control via the HTML5 api.

The default value is false.


Implementation
    public function get isDraggedOver():Boolean
isDroppingproperty 
isDropping:Boolean  [read-only]

Return whether a drag is being processed.

The default value is false.


Implementation
    public function get isDropping():Boolean
isSupportedproperty 
isSupported:Boolean  [read-only]

Return whether the ExternalInterface supports the HTML5 drag and drop API.

The default value is false.


Implementation
    public function get isSupported():Boolean
Method Detail
dragDropErrorHandler()method
protected function dragDropErrorHandler(frameId:String, error:String, file:Object):void

Handles error events returned by javascript. Called by javascript.

Parameters

frameId:String — the frameId of the frame that fired the handler
 
error:String — the String description of the error
 
file:Object — the javascript File object

dragHandler()method 
protected function dragHandler(frameId:String, type:String, dataTransfer:Object, types:Array):Array

Handles the drag events. Called by javascript.

Parameters

frameId:String — the frameId of the frame that fired the handler
 
type:String — the type of event
 
dataTransfer:Object — the javascript dataTransfer object
 
types:Array — the mime types of the dragged elements

Returns
Array — array of potentially changed dropEffect, effectAllowed properties
dropHandler()method 
protected function dropHandler(frameId:String, type:String, file:Object = null, data:* = null, progress:Object = null):Boolean

Handles drop events. Called by javascript.

Parameters

frameId:String — the frameId of the frame that fired the handler
 
type:String — the type of javascript event
 
file:Object (default = null) — the javascript File object
 
data:* (default = null) — file data
 
progress:Object (default = null) — the javascript Progress event

Returns
Boolean — true to cancel the drop, only for the "starting" event
Event Detail
abortErr Event
Event Object Type: ardisia.components.htmlDragDrop.events.HtmlDragDropErrorEvent
HtmlDragDropErrorEvent.type property = ardisia.components.htmlDragDrop.events.HtmlDragDropErrorEvent

Dispatched when the dropped file was being read into a data buffer, but was aborted.

browserNoSupportErr Event  
Event Object Type: ardisia.components.htmlDragDrop.events.HtmlDragDropErrorEvent
HtmlDragDropErrorEvent.type property = ardisia.components.htmlDragDrop.events.HtmlDragDropErrorEvent

Dispatched when the browser does not support file drag and drop.

dragDropStarting Event  
Event Object Type: ardisia.components.htmlDragDrop.events.HtmlDragDropEvent
HtmlDragDropEvent.type property = ardisia.components.htmlDragDrop.events.HtmlDragDropEvent

Dispatched immediately after a drop is initiated over the control. Can be cancelled to prevent the drop. The first drop event to fire.

dragEnter Event  
Event Object Type: ardisia.components.htmlDragDrop.events.HtmlDragDropEvent
HtmlDragDropEvent.type property = ardisia.components.htmlDragDrop.events.HtmlDragDropEvent

Dispatched when the user drags over the control.

dragLeave Event  
Event Object Type: ardisia.components.htmlDragDrop.events.HtmlDragDropEvent
HtmlDragDropEvent.type property = ardisia.components.htmlDragDrop.events.HtmlDragDropEvent

Dispatched when the user drags out of the control.

dragLoad Event  
Event Object Type: ardisia.components.htmlDragDrop.events.HtmlDragDropEvent
HtmlDragDropEvent.type property = ardisia.components.htmlDragDrop.events.HtmlDragDropEvent

Dispatched when a dropped file has been fully processed by both javascript and actionscript and is available as a ByteArray.

The final drop event to fire.

dragLoadStart Event  
Event Object Type: ardisia.components.htmlDragDrop.events.HtmlDragDropEvent
HtmlDragDropEvent.type property = ardisia.components.htmlDragDrop.events.HtmlDragDropEvent

Dispatched when a drop file is initially being read into memory. The second drop event to fire.

dragOver Event  
Event Object Type: ardisia.components.htmlDragDrop.events.HtmlDragDropEvent
HtmlDragDropEvent.type property = ardisia.components.htmlDragDrop.events.HtmlDragDropEvent

Dispatched continuously when the user is dragging over the control.

dragProgress Event  
Event Object Type: ardisia.components.htmlDragDrop.events.HtmlDragDropEvent
HtmlDragDropEvent.type property = ardisia.components.htmlDragDrop.events.HtmlDragDropEvent

Dispatched while the dropped file is being read into a buffer by the browser. This will not reflect the time it takes the flex app to decode the data buffer into a ByteArray.

The third drop event to fire. Returns the percent loaded.

notFoundErr Event  
Event Object Type: ardisia.components.htmlDragDrop.events.HtmlDragDropErrorEvent
HtmlDragDropErrorEvent.type property = ardisia.components.htmlDragDrop.events.HtmlDragDropErrorEvent

Dispatched when the dropped file was not found.

notReadableErr Event  
Event Object Type: ardisia.components.htmlDragDrop.events.HtmlDragDropErrorEvent
HtmlDragDropErrorEvent.type property = ardisia.components.htmlDragDrop.events.HtmlDragDropErrorEvent

Dispatched when the dropped file was not readable by the browser.

unknownErr Event  
Event Object Type: ardisia.components.htmlDragDrop.events.HtmlDragDropErrorEvent
HtmlDragDropErrorEvent.type property = ardisia.components.htmlDragDrop.events.HtmlDragDropErrorEvent

Dispatched when the error was unknown.