Thursday, September 06, 2007

So here is a simple example of dragging and dropping file attachments that exist on a server (from your OS to your AIR/Flex component and vice versa).

As a user initiates the drag on any UI component that implements DisplayObject, a URLLoader will be instantiated and the loader.load(urlRequest) will begin to download the attachment. The drag icon will also appear. When the user drops, the file is written to the disk using the FileStream class.

Here is a simple example of how to do that. There is both a mx.Button and rows within a mx.List that use the same simple piece of logic. I created a sublcass of both Button and List, which implement the same IDragFile interface. It is very simple. Here is the link to theAIR file with the source included within the AIR.


ZIP (Source)