Tips: イベント関連
NativeDragEventを受け取れない(AIR β2/β3)
CANVASコンテナにbackgroundColorを設定しないとNativeDragEventをなぜか受け取れないmyApplication.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" applicationComplete="init()">
<mx:Script source="myApplication.as"/>
<mx:Canvas id="canvas" percentWidth="100" percentHeight="100" backgroundColor="#FFFFFF" />
</mx:WindowedApplication>
myApplication.as:
import flash.desktop.*;
import flash.events.*;
private function init():void {
canvas.addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER, DragEnterHandler);
}
private function DragEnterHandler(event:NativeDragEvent):void {
if (event.clipboard.hasFormat(ClipboardFormats.FILE_LIST_FORMAT)) {
DragManager.acceptDragDrop(canvas);
canvas.addEventListener(NativeDragEvent.NATIVE_DRAG_DROP, DragDropHandler);
}
}
private function DragDropHandler(event:NativeDragEvent):void {
var fileList:Array = event.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;
trace(fileList[0].nativePath);
}
何でですかね?CANVAS以外のコンテナクラスはどう何だろう?
【追記 2007.12.15】
AIR β3でも同様でした。