2 Replies Latest reply on May 29, 2012 5:32 PM by peter7455

    Please Help! Drag and drop does not work in Adobe AIR 3.1 (FlashBuilder 4.6)

    peter7455

      I am working on a PC is made of air and flashbuilder 4.6.

      Drag and drop application does not work in Flash Builder 4.6.

      However, the same source will work with Flash Builder 4.5.

      Please help me.

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                    xmlns:s="library://ns.adobe.com/flex/spark" 
                                    xmlns:mx="library://ns.adobe.com/flex/mx" 
                                    backgroundColor="#323232" width="100%" height="100%"
                                    initialize="init(event)"
                                    nativeDragEnter="onDragEnter(event)"
                                    nativeDragDrop="onDragDrop(event)">
                <fx:Script>
                <![CDATA[
                          import mx.events.FlexEvent;
      
                          protected function init(event:FlexEvent):void
                          {
                                    addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER, onDragEnter);
                                    addEventListener(NativeDragEvent.NATIVE_DRAG_DROP, onDragDrop);
                          }
      
                          private function onDragEnter(event:NativeDragEvent):void
                          {
                                    if (event.clipboard.hasFormat(ClipboardFormats.FILE_LIST_FORMAT))
                                    {
                                              NativeDragManager.acceptDragDrop(this);
                                    }
                          }
      
                          private function onDragDrop(event:NativeDragEvent):void
                          {
                                    var arr:Array;
                                    arr = Array(event.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT));
                                    startImage.source = (arr[0] as File).url;
                          }
                  ]]>
                </fx:Script>
                <s:layout>
                          <s:VerticalLayout/>
                </s:layout>
      
                <s:BorderContainer id="bc" borderStyle="solid" width="200" height="80%"/>
                <s:Image id="startImage" width="100%" height="100%" 
                                               horizontalAlign="center" verticalAlign="middle"/>
        </s:WindowedApplication>