See code below. After you drag an item from the list and drop it into 
the Canvas, how you do then drag the item you just dropped, have it 
run the dragDropHandler function, and then move the original item?

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; 
layout="absolute" width="500" height="620" borderStyle="solid" 
creationComplete="initApp();">

<mx:Script>
        <![CDATA[
                import mx.controls.Button;
                        import mx.controls.Alert;
            import mx.events.DragEvent;
            import mx.controls.List;
            import mx.managers.DragManager;
            import mx.core.DragSource;
                        
            private function initApp():void {
                var dp:Array = ([
                    {label:"First", data:"25"},
                    {label:"Second", data:"50"},
                    {label:"Third", data:"75"},
                    {label:"Fourth", data:"100"},
                ]);
                listOne.dataProvider = dp;
            }
            
            private function dragEnterHandler(event:DragEvent):void {
                var dropTarget:Canvas=event.currentTarget as Canvas;
                    dropTarget.setStyle("borderThickness", 5);
                    DragManager.acceptDragDrop(dropTarget);
                }
                
            private function dragExitHandler(event:DragEvent):void {
                var dropTarget:Canvas=event.currentTarget as Canvas;
                                revertBoxBorder();                
            }
            
            private function dragDropHandler(event:DragEvent):void {
                var dropTarget:Canvas=event.currentTarget as Canvas;
                                var buttonA:Button = new Button;
                                buttonA.label = 
listOne.selectedItem.label;
                                if (dropTarget.mouseY.valueOf() >= 0 
&& dropTarget.mouseY.valueOf() < 100) {
                                        buttonA.y = 0;
                                        buttonA.y = 0;
                                }
                                if (dropTarget.mouseY.valueOf() >= 
100 && dropTarget.mouseY.valueOf() < 200) {
                                        buttonA.x = 00;
                                        buttonA.y = 100;        
                                
                                }                               
        
                                dropBox.addChild(buttonA);
                revertBoxBorder();                
            }
                           
            private function revertBoxBorder():void {
                dropBox.setStyle("borderThickness", 
1);                
            }                
        ]]>
</mx:Script>
                <mx:List id="listOne" dragEnabled="true" 
dropEnabled="true" x="10" y="10"></mx:List>
                <mx:Canvas x="180" y="10" width="308" height="498" 
borderStyle="solid" borderColor="#000000" backgroundColor="#FFFFFF" 
                        dragEnter="dragEnterHandler(event);" 
id="dropBox" dragExit="dragExitHandler(event);"
                        dragDrop="dragDropHandler(event);">     
                </mx:Canvas>
</mx:Application>


Reply via email to