4 Replies Latest reply on Aug 18, 2008 7:38 AM by kiwi_ziesch

    don´t allow drag&drop

    kiwi_ziesch Level 1
      In my app you can drag&drop images from the file system into air. but now I want to forbid to drag and drop the image inside the application. now I get this error message when dragging images inside my app:
      "TypeError: Can't get property length from null value"
      and when I browse for images and then drag them inside my app I get this error message:
      "ArgumentError: Error #2015: Invalid BitmapData.
      at flash.display::BitmapData()
      at flash.html::HTMLLoader/nativeOnMouseMove()
      at flash.html::HTMLLoader/onMouseMove()"

      so, how can I forbid to drag images inside my app or just solve these errors?
      Thanks a lot!
        • 1. Re: don´t allow drag&drop
          Check the DragEvent instance in the DragEnter event listener funciton.
          There are differences in the DragEvent instance's properties between Dragging from the file system and Dragging from inside.
          • 2. Re: don´t allow drag&drop
            kiwi_ziesch Level 1
            sorry, but...I don´t know how to do this...
            here´s my code for drag&drop into the app:

            var filelist = event.clipboard.getData(air.ClipboardFormats.FILE_LIST_FORMAT);

            var elem = null;
            var name = null;

            if (filelist.length) {
            for (var f = 0; f < filelist.length; f++) {
            name = filelist[f].name;

            elem = document.getElementById('list5');
            elem.innerHTML += name;

            function preventDefault(event){
            • 3. Re: don´t allow drag&amp;drop
              paravoice Level 1
              oh, I see.
              I think you should check the clipboard in the NativeDragEvent listener function.
              for example

              var filelist = event.clipboard.getData(air.ClipboardFormats.FILE_LIST_FORMAT);

              if (filelist != null) {
              // If the filelist is not null, in other words, when dragging from outside, accept the drop.
              DragManager.acceptDragDrop(event.currentTarget as IUIComponent);
              • 4. Re: don´t allow drag&amp;drop
                kiwi_ziesch Level 1
                thanks but...I don´t know. maybe 9h AIR is to much for me. I don´t know where to put your code. Or shall I replace "...window.htmlLoader.addEventListener("nativeDragDrop",function(event){ ..." with your code, or mix it up?

                By the way, I got an error message in my editor when adding the line "DragManager.acceptDragDrop(event.currentTarget as IUIComponent);"
                error: "multiple items at this position missing ) after argument list"

                thanks fot any help