<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute" width = "450" Height = "350" creationcomplete = "initapp () "backgroundcolor =" # ffffff "fontsize =" 12 ">
<Mx: SCRIPT>
<! [CDATA [
Private function initapp (): void {
Words. dataprovider = ['water', 'water', 'car', 'auto', 'house', 'house', 'book', 'book', 'music ', 'music ',
'Sandwich ', 'sandwich']; English. dataprovider = []; Chinese. dataprovider = [];
}
]>
</MX: SCRIPT>
<Mx: panel X = "0" Y = "0" width = "450" Height = "350" layout = "absolute" Title = "Sort words by language">
<Mx: Label x = "7" Y = "3" text = "drag to correct language"/>
<Mx: list x = "7" Y = "25" id = "Words" width = "200" Height = "275" allowmultipleselection = "true" dragenabled = "true"> </MX: list>
<Mx: Label x = "223" Y = "6" text = "English"/>
<Mx: List x = "223" Y = "25" id = "English" width = "200" Height = "120" dropenabled = "true"> </MX: list>
<Mx: Label x = "223" Y = "150" text = "Chinese"/>
<Mx: List x = "223" Y = "177" id = "Chinese" width = "200" Height = "120" dropenabled = "true"> </MX: list>
</MX: Panel>
</MX: Application>
:
<? XML version = "1.0" encoding = "UTF-8"?>
<Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" width = "400" Height = "400" backgroundcolor = "# ffffff"
Creationcomplete = "initapp ()" layout = "absolute">
<Mx: SCRIPT>
<! [CDATA [
Import MX. Controls. DataGrid;
Import MX. Controls. image;
Import MX. Collections. arraycollection;
Import MX. Events. dragevent;
Import MX. Managers. dragmanager;
Import MX. Core. dragsource;
[Bindable]
Public var Total: Number = 0;
[Bindable]
Public var cartcontents: arraycollection;
Private function initapp (): void {
This. cartcontents = new arraycollection ();
}
Private function dragit (Event: mouseevent, name: String, price: Number): void {
// Currenttarget specifies the initialization target of the drag-and-drop event.
VaR draginitiator: Image = event. currenttarget as image;
// Specify a dragsource to include the data objects contained in the drag process
VaR dragsource: dragsource = new dragsource ();
// Add data to the object
Dragsource. adddata (name, 'name ');
Dragsource. adddata (price, 'price ');
// Create a copy object proxy
VaR dragproxy: Image = new image ();
Dragproxy. Source = event. currenttarget. source;
// Use the dragmanager static method dodrag to start dragging
Dragmanager. dodrag (draginitiator, dragsource, event, dragproxy );
}
Private function dragenterhandler (Event: dragevent): void {
VaR droptarget: DataGrid = event. currenttarget as DataGrid;
If (event. dragsource. hasformat ('name') & event. dragsource. hasformat ('price ')){
Dragmanager. acceptdragdrop (droptarget );
}
}
Private function dragdrophandler (Event: dragevent): void {
VaR name: String = string (event. dragsource. dataforformat ('name '));
VaR price: Number = Number (event. dragsource. dataforformat ('price '));
This. cartcontents. additem ({Name: string (event. dragsource. dataforformat ('name '))
, Price: string (event. dragsource. dataforformat ('price '))});
Total + = price;
}
]>
</MX: SCRIPT>
<Mx: canvas x = "19" Y = "10">
<Mx: Image x = "23" Y = "35" width = "64" Height = "64" mousemove = "dragit (event, 'dreamweaver ', 499 ); "Source =" @ embed (Source = '.. /images/01.png ') "/>
<Mx: Label x = "41" Y = "107" text = "499"/>
<Mx: Image x = "23" Y = "133" width = "64" Height = "64" mousemove = "dragit (event, 'fireworks', 299 ); "Source =" @ embed (Source = '.. /images/02.png ') "/>
<Mx: Label x = "41" Y = "205" text = "299"/>
<Mx: Image x = "23" Y = "231" width = "64" Height = "64" mousemove = "dragit (event, 'flash', 599 ); "Source =" @ embed (Source = '.. /images/03.png ') "/>
<Mx: Label x = "41" Y = "303" text = "599"/>
</MX: canvas>
<Mx: Label x = "210" Y = "61" text = "Shopping Basket" fontsize = "12"/>
<Mx: DataGrid x = "129.5" Y = "102" id = "cart" dataprovider = "{cartcontents}" dragenter = "dragenterhandler (event ); "dragdrop =" dragdrophandler (event); "Height =" 165 "fontsize =" 12 ">
<Mx: columns>
<Mx: datagridcolumn headertext = "product" datafield = "name"/>
<Mx: datagridcolumn headertext = "price" datafield = "price"/>
</MX: columns>
</MX: DataGrid>
<Mx: Label x = "186" Y = "292" text = "Total: {total}" fontsize = "12"/>
<Mx: Label x = "129.5" Y = "0" text = "drag an item into the basket" fontsize = "12"/>
<Mx: hrule x = "5" Y = "20" width = "390"/>
</MX: Application>
: