Header Photo Info

Golden Gate Park, San Francisco
-- taken May 2008
.

View Steve Rogers's profile on LinkedIn

My status

Simple Drag and Drop

Simple drag and drop example

This is a straight forward article on coding up a drag and drop application in AIR, along with the actual application that can be downloaded (with source).

This is a beta 1 example that may not work with the beta 2 runtime as it looks like changes have been made to the native drag and drop libaries - i will test and update when I can.

The example is very simple and has commenting in the source code on what is being done.

Overview
The steps required for this drag and drop example are:

  • set up the required event handlers so that drag and drop can be detected and acted on - in this example that is dragEnter, dragExit and dragDrop
  • In dragEnter check the initiator of the drag action and if ok inform the dragManager which object will accept the dragged item
  • dragExit is used to provide visual indication that the object will accept the dragged item (border color change)
  • dragDrop is used to gather the details of the object that was dropped and pass the details to the method that displays the image

There is a lot of stuff missing, such as checking filetypes, handling more that one file etc, etc. But the the code here is just an example of getting drag and drop working so it has been kept as simple as possible.

The attached files that can be downloaded are as follows

  • dragdrop.zip - zip of the Flex builder project directory with all files
  • dragdrop.air - the installable drap and drop example application

To run and install the AIR application you will need the appropriate runtime. see http://labs.adobe.com/downloads/air.html for more details.

AttachmentSize
dragdrop.zip1.67 MB
dragdrop.air722.93 KB

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br> <img>
  • Lines and paragraphs break automatically.

More information about formatting options

User login

Recent comments