10/10/2011 4:37:21 AM
Title:
Air Native drag-drop not working with child container canvas.
Hello Everybody,
Currently I am working with native drag-drop with air application. In this application their is a canvas container, and I am dragging images from desktop to this canvas container and this canvas container is a child of application.
Here all the code of drag drop is working, when I wrote it in main application file. but when I wrote it with canvas, the drag drop is not working
I am having following code for drag drop
<mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%" initialize="initHandler()">
<fx:Script>
<![CDATA[
import mx.managers.DragManager;
import flash.events.NativeDragEvent;
import flash.desktop.NativeDragManager;
import flash.desktop.Clipboard;
import flash.desktop.ClipboardFormats;
private function initHandler():void
{
this.addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER,onDragInHandler);
this.addEventListener(NativeDragEvent.NATIVE_DRAG_DROP,onDropHandler);
// this.addEventListener(NativeDragEvent.NATIVE_DRAG_EXIT,onDragExitHandler);
}
private function onDragInHandler(nativeDragEvent:NativeDragEvent):void
{
DragManager.acceptDragDrop(this);
}
private function onDropHandler(nativeDragEvent:NativeDragEvent):void
{
var dropfiles:Array=nativeDragEvent.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;
for each (var file:File in dropfiles)
{
switch (file.extension)
{
case "png" :
addImage(file.nativePath);
break;
case "jpg" :
addImage(file.nativePath);
break;
case "gif" :
addImage(file.nativePath);
break;
default:
Alert.show("default error");
}
}
}
private function addImage(value:String):void
{
Alert.show("image drag sucessfully');
}
Please tell me what I am missing for canvas. Its working with main container not with child container canvas
10/12/2011 11:28:55 PM
The bug has solved. just set some background property for that canvas