Preview Message
Hi All,
As all of us know by defaulf Flex provides drag and
drop features for DataGrid,List,Tree etc.Am using the List Control and
while dragging an item in the list i wanted to display an icon
(probably a small image) instead of the actual item and i have
implemented this feature by making use of doDrag() of DragManager
Class on mouseMove event for List Control.
Now the problem is that the default behavior for List
Control i.e. drop enabled not working when i tried to change the order
of the items though it is set as true.
How do i solve this problem?Can any one help me to solve this?
Here is the code i have implemeneted ............
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
verticalCenter="0" horizontalCenter="0"
width="50%" height="50%">
<mx:Script>
<![CDATA[
import mx.core.IUIComponent;
import mx.collections.ArrayCollection;
import mx.managers.DragManager;
import mx.core.DragSource;
import mx.controls.Image;
import mx.events.DragEvent;
import mx.controls.Alert;
[Bindable]
private var initData:ArrayCollection = new
ArrayCollection([
{book:"DBMS",author:"Sudarshan"},
{book:"C",author:"Yaswanth Kanethkar "},
{book:"C+
+",author:"JBalaguruswamy"},
{book:"Software Engineering",author:"Pressman"}]);
private function onMouseMove(event:MouseEvent):void {
var dragInitiator:List = List
(event.currentTarget);
var dragSource:DragSource = new DragSource();
dragSource.addData(dragInitiator,"image");
var displayIcon:Image = new Image();
displayIcon.source = "resources/images/
paper_content_48.png";
displayIcon.width = 50;
displayIcon.height = 50;
displayIcon.x = List(event.currentTarget).mouseX;
displayIcon.y = List(event.currentTarget).mouseY;
DragManager.doDrag
(dragInitiator,dragSource,event,displayIcon,20, 20, 2.00);
}
private function image_dragEnter(event:DragEvent):void
{
var obj:IUIComponent = IUIComponent
(event.currentTarget);
DragManager.acceptDragDrop(obj);
}
private function image_dragDrop(event:DragEvent):void
{
//code to remove the item from the database
}
]]>
</mx:Script>
<mx:List width="100%" height="100%" dragEnabled="true"
dropEnabled="true" dragMoveEnabled="true"
mouseMove="onMouseMove(event)" dataProvider="{initData}">
<mx:itemRenderer>
<mx:Component>
<mx:VBox width="100%" height="100%">
<mx:HBox>
<mx:CheckBox/>
<mx:Label text="Book:{data.book}"/>
</mx:HBox>
<mx:Label text="Author:{data.author}"
paddingLeft="25"/>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:List>
<mx:Image id="trashIcon" source='resources/images/
recycle_bin_blue_50x50.png'
toolTip="Recycle Bin" dragDrop="image_dragDrop
(event)" dragEnter="image_dragEnter(event)" />
</mx:Application>
Close Window
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---