fuoco
未読、2008/10/24 9:18:122008/10/24投稿者に返信する場合はログインしてください
転送する場合はログインしてください
このグループ内のメッセージを削除する権限がありません
メッセージを報告するにはログインしてください
メールアドレスがこのグループでは匿名化されているか、メンバーのメールアドレスを表示する権限がないため、元のメッセージを表示できません
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:
<mx:Panel
nativeDragEnter="onDragIn(event)"
nativeDragDrop="onDrop(event)"
/>
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.