Tuesday, March 30, 2010

Drag and Drop with multiple lists

Hi,

I'm new to Flex development and having trouble with a particular problem.

I'm after placing 4 lists on a particular form and allowing drag and drop on each list. However list one can only drag onto list two and vice versa and list three can only drop onto list four and vice versa. My problem is that I cant figure out how to limit what each list can accept from other lists. I've tried created dragEnter and dragDrop events but am having difficulties. Any help would be much appreciated.

Thanks

Simon

Drag and Drop with multiple lists

%26lt;mx:List id=''listTotalsBy'' dragEnter=''doDragEnter(event);'' mouseDown=''setDragInitator(event, 'listTotalsBy');'' /%26gt;


private var dropInitiator:String


public function setDragInitator(event:MouseEvent, id:String):void
{
?dropInitiator = id;
}


/**
* this method will call while drag %26amp; drop will start %26amp; used to set initial parameters for drag %26amp; drop
* activity.
*/
public function doDragEnter(event:DragEvent):void
{
?try
?{
?var dropTarget:List = List(event.currentTarget);
?
?if(dropInitiator == ''listTotalsBy'' %26amp;%26amp; (dropTarget.id == ''listSelectedTotalsBy'' || dropTarget.id == ''listTotalsBy'' ))/*here u can make a choice*/
?{?
?DragManager.showFeedback(DragManager.MOVE);
?DragManager.acceptDragDrop(dropTarget);
?}

?}
?catch(error :Error)
?{
?Alert.show(''error : '' + error.getStackTrace());
?}
}


No comments:

Post a Comment