You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Bulgaria Flex User Group
Hello.
I would like to show an easy way to drag and drop files from
filesystem within your Air applications.
The well-known technology Drag And Drop allows users to drag file or
files list and drop it or them on several component of your Air
Application.
Let we have a panel:
<mx:Panel />
In order to make this panel accept files being dragged and dropped
over it, we handle these events:
The first event nativeDragEnter is a good point to set the mouse
cursor by putting this code in it:
public function onDragIn(event:NativeDragEvent):void
{
if (event.clipboard.hasFormat('air:file list')) // only accept files
list
DragManager.acceptDragDrop(this); // set the "+" mouse cursor
}
The second event nativeDragDrop is the adequate place to read the
files being dropped:
public function onDrop(event:NativeDragEvent):void
{
var dropfiles:Array =
event.clipboard.getData('air:file list') as Array;
for each (var file:File in dropfiles)
{
importFile(file);
}
}
Comment: the clipboard field of the NativeDragEvent argument does not
seem to have anything common with the windows clipboard holder's
content.
Finally you have access to the imported files by the dropfiles array,
get as a clipboard data format 'air:file list'.
Hope this to be helpful if someone needs to import files using drag
and drop.