nativeDragEnter="dragEnterHandler(event);" //进入
nativeDragDrop="dragDropHandler(event);"//放下
private function dragEnterHandler(event:NativeDragEvent):void {
var transferable:Clipboard = event.clipboard; //取得剪贴板里的东西
if (transferable.hasFormat(ClipboardFormats.FILE_LIST_FORMAT)) //是否有文件列表
{
DragManager.acceptDragDrop(this.box); //让box目标接受拖动的放置
//目标必须是是IUIComponent
}
}
private function dragDropHandler(event:NativeDragEvent):void {
var arr:Array = event.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;
if (arr.length==0) return;
pic.source = (arr[0] as File).url;
}