I spend a lot of time talking with Financial Services organizations, and this is a feature that they are really interested in.
This is “native” drag-and-drop handled by the operating system. The way it works is that, on “drag start” in your application, you are responsible for packaging the relevant data in one or different formats (text, bitmap, file). When the user mouses over another desktop application, that application will look at the formats available, and decide if it wants to accept a drop. If it does, it will adjust the drag icon accordingly and consume the data as appropriate if the user releases the mouse button.
I have been using this feature in the SalesBuilder application I posted yesterday. In the process of building SalesBuilder I created two utility classes to abstract the details of generating bitmaps, XLS files, etc…
DragBitmap allows you to drag any Flex visual component and drop it on the desktop as JPG or in any other application that accepts bitmaps.
To use it simply add the following line to your code:
<DragBitmap displayObject=”{myChart}”/>
DragBitmap packages your data in two formats: a raw bitmap format and a JPG file.
DragExcel allows you to drag the selected rows of a Datagrid and drop them on the desktop as an XLS file or directly in an open Excel spreadsheet.
To use it simply add the following line to your code:
<DragExcel dataGrid=”{dg}”/>
DragExcel packages your data in two formats: a raw text format and an HTML file with an XLS extension (Excel can read HTML table). A CSV format may be a better choice for greater portability.
Click here to install a very simple sample application.
This application is just a few lines of code…
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
creationComplete="srv.send()">
<mx:ArrayCollection id="results"/>
<mx:HTTPService id="srv" url="results.xml"/>
<mx:Binding source="srv.lastResult.data.item" destination="results"/>
<DragBitmap displayObject="{lc}"/>
<DragExcel dataGrid="{dg}"/>
<mx:DataGrid id="dg" dataProvider="{results}" allowMultipleSelection="true"/>
<mx:ColumnChart id="lc" dataProvider="{results}">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="month"/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries yField="revenue"/>
<mx:ColumnSeries yField="costs"/>
</mx:series>
</mx:ColumnChart>
</mx:WindowedApplication>
… and allows you to:<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
creationComplete="srv.send()">
<mx:ArrayCollection id="results"/>
<mx:HTTPService id="srv" url="results.xml"/>
<mx:Binding source="srv.lastResult.data.item" destination="results"/>
<DragBitmap displayObject="{lc}"/>
<DragExcel dataGrid="{dg}"/>
<mx:DataGrid id="dg" dataProvider="{results}" allowMultipleSelection="true"/>
<mx:ColumnChart id="lc" dataProvider="{results}">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="month"/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries yField="revenue"/>
<mx:ColumnSeries yField="costs"/>
</mx:series>
</mx:ColumnChart>
</mx:WindowedApplication>
- Drag selected rows in the DataGrid and drop them to the desktop as an XLS file or directly in an open Excel spreadsheet.
- Drag the chart and drop it on the desktop as a JPG file or directly in an Open Word document (or any other application that consumes bitmaps).
These are very basic classes. They can certainly be improved in many ways, but hopefully they can give you a jumpstart when experimenting with AIR-to-desktop drag-and-drop.
Click here to download the source code.
作者:gdgzboy@牛C网
地址:http://www.niuc.net/post/268/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
牛C网推荐您再看看以下日志:
Programming Flex 2 书籍下载
Join me next week for a Flex seminar in Paris, Brussels, and Noordwijk
Silverlight vs Flex
中国地图 FLEX( API )发放
A simple FLEX VIDEO SOURCE
Flex中数据绑定技巧
Salesbuilder source code available
Offline Synchronization using AIR and LiveCycle Data Services
New MDI-style Trader Desktop with Flex and Apollo
用Flex从前往后创建RIAs 第二部分
Programming Flex 2 书籍下载
Join me next week for a Flex seminar in Paris, Brussels, and Noordwijk
Silverlight vs Flex
中国地图 FLEX( API )发放
A simple FLEX VIDEO SOURCE
Flex中数据绑定技巧
Salesbuilder source code available
Offline Synchronization using AIR and LiveCycle Data Services
New MDI-style Trader Desktop with Flex and Apollo
用Flex从前往后创建RIAs 第二部分
SalesBuilder on AIR: Local Database, Data Syn
SQLQueue: Chaining Asynchronous SQL statement





