Drag and drop label value to a List : List Label « Components « Flex






Drag and drop label value to a List

Drag and drop label value to a List
           
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
  <mx:Script>
    
    import mx.collections.ArrayCollection;
    import mx.core.*;
    import mx.managers.DragManager;
    import mx.events.DragEvent;
    [Bindable]
    private var targetData:ArrayCollection = new ArrayCollection();
    private function dragTest(initiator:Label, myData:String, event:MouseEvent, format:String):void
    {
      var ds:DragSource = new DragSource();
      ds.addData(myData, format);
      DragManager.doDrag(initiator, ds, event);
    }
    private function listDragEnter(evt:DragEvent, format:String):void
    {
      DragManager.acceptDragDrop(IUIComponent(evt.target));
    }
    private function listDragDrop(evt:DragEvent, format:String):void
    {
      var myData:Object = new Object();
      myData = evt.dragSource.dataForFormat(format);
      myList.dataProvider.addItem(myData);
    }
    
  </mx:Script>
  <mx:Label id="dragLabel" text="Drag this Label" mouseDown="dragTest(dragLabel, 'A', event, 'stringFormat')" />
  <mx:List  id="myList" 
            dataProvider="{targetData}"
          dragEnter="listDragEnter(event, 'stringFormat')"
          dragDrop="listDragDrop(event, 'stringFormat')" />
</mx:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Using labelField to tell List which column to presentUsing labelField to tell List which column to present
2.Combine label and data for List itemCombine label and data for List item
3.Using a label function with one-column List-based componentsUsing a label function with one-column List-based components
4.Using a label function to support a single-column List componentUsing a label function to support a single-column List component
5.Get selected item label from a listGet selected item label from a list
6.Format List with labelFunction propertyFormat List with labelFunction property
7.Set label field for data source of List controlSet label field for data source of List control
8.Using a function to combine the values of the label and data fields for each item for display in the List controlUsing a function to combine the values of the label and data fields for each item for display in the List control
9.Use a label function to concatenate the firstName and lastName fields of each data item for display by the controlUse a label function to concatenate the firstName and lastName fields of each data item for display by the control