当我将图像放到画布上时,我可以获得图像的 nativePath,但不能获得我需要的位图数据。
在调试模式下,当我查看文件属性时,数据设置为 NULL。
我在这里做错了什么?在我的代码file.data
中没有给我任何东西。
protected function creationCompleteHandler(event:FlexEvent):void
{
this.addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER,onDragIn);
this.addEventListener(NativeDragEvent.NATIVE_DRAG_DROP,onDrop);
NativeDragActions.COPY;
}
private function onDrop(e:NativeDragEvent):void
{
trace("Dropped!");
var dropfiles:Array = e.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;
for each (var file:File in dropfiles){
switch (file.extension.toLowerCase()){
case "png" :
trace('png');
//resizeImage(file.nativePath);
break;
case "jpg" :
trace('jpg');
//resizeImage(file.nativePath);
break;
case "jpeg" :
trace('jpeg');
//resizeImage(file.nativePath);
break;
case "gif" :
resizeImage(file.nativePath);
break;
default:
Alert.show("choose an image file!");
}
}
}