Drag Drop To Component : Drag Drop « Development « Flex






Drag Drop To Component

Drag Drop To Component
          

<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->



    <!-- charts/DragDropToComponent.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark"
    creationComplete="srv.send()" height="600">
    <fx:Declarations>
        <!--
            View source of the following page to see the structure of the data
            that Flex uses in this example.
        -->
        <mx:HTTPService id="srv"
            url="http://aspexamples.adobe.com/chart_examples/medals-xml.aspx" />
        <!--
            To see data in an HTML table, go to
            http://aspexamples.adobe.com/chart_examples/medals.aspx
        -->
    </fx:Declarations>
    <fx:Script> 
         
        import mx.collections.ArrayCollection; 
        import mx.events.DragEvent; 
        import mx.controls.List; 
        import mx.managers.DragManager; 
        import mx.core.DragSource; 
        import mx.charts.chartClasses.ChartBase; 
        import mx.charts.ChartItem; 
        import mx.charts.events.ChartItemEvent; 
        import mx.charts.series.items.ColumnSeriesItem; 
        private function doDragEnter(event:DragEvent):void { 
            var dragTarget:TextArea = TextArea(event.currentTarget); 
            DragManager.acceptDragDrop(dragTarget); 
        } 
        private function doDragDrop(event:DragEvent):void { 
            var dropTarget:TextArea = TextArea(event.currentTarget); 
            var curItem:ColumnSeriesItem = ColumnSeriesItem(event.dragSource.dataForFormat("chartitems")[0]); 
            var curSeries:ColumnSeries = ColumnSeries(curItem.element); 
            var medalType:String = curSeries.displayName; 
            var numMedals:String = curItem.yValue.toString(); 
            var countryName:String = curItem.item.country; 
            ta1.text = countryName + " earned " + numMedals + " " + medalType + " medals."; 
        } 
      
    </fx:Script>
    <s:layout>
        <s:VerticalLayout />
    </s:layout>
    <s:Panel title="Dropping ChartItem Objects">
        <s:layout>
            <s:VerticalLayout />
        </s:layout>
        <mx:ColumnChart id="myChart" height="225" showDataTips="true"
            dataProvider="{srv.lastResult.data.result}" selectionMode="single"
            dragEnabled="true">
            <mx:horizontalAxis>
                <mx:CategoryAxis categoryField="country" />
            </mx:horizontalAxis>
            <mx:series>
                <mx:ColumnSeries id="columnSeries1" xField="country"
                    yField="gold" displayName="Gold" selectable="true" />
                <mx:ColumnSeries id="columnSeries2" xField="country"
                    yField="silver" displayName="Silver" selectable="true" />
                <mx:ColumnSeries id="columnSeries3" xField="country"
                    yField="bronze" displayName="Bronze" selectable="true" />
            </mx:series>
        </mx:ColumnChart>
        <s:HGroup>
            <mx:Legend dataProvider="{myChart}" />
            <s:TextArea id="ta1" height="75" width="200"
                dragEnter="doDragEnter(event)" dragDrop="doDragDrop(event)" />
        </s:HGroup>
    </s:Panel>
</s:Application>

   
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Setting the dragMoveEnabled property to move instead of copySetting the dragMoveEnabled property to move instead of copy
2.Dragging and dropping within a component, to allow orderingDragging and dropping within a component, to allow ordering
3.Create DragSource object and add data to itCreate DragSource object and add data to it
4.Performing a two-way drag and dropPerforming a two-way drag and drop
5.Dragging and dropping in the same controlDragging and dropping in the same control
6.The drag initiators, and drop targetThe drag initiators, and drop target
7.Get Drag source data formatGet Drag source data format
8.Press control key as drag and dropPress control key as drag and drop
9.Canvas Drag and DropCanvas Drag and Drop
10.Specifying the drag indicator by using the DragSpecifying the drag indicator by using the Drag
11.Specify a Drag ProxySpecify a Drag Proxy
12.Enable and Disable Drag OperationsEnable and Disable Drag Operations
13.Set liveDragging to true to dispatch change event continuously as moving the thumbSet liveDragging to true to dispatch change event continuously as moving the thumb
14.Get drag source from DragEventGet drag source from DragEvent
15.Canvas drag enter eventCanvas drag enter event
16.Explpicitly handle the dragOver eventExplpicitly handle the dragOver event