I finished a working dragDrop function today, but ran into a bit of a
problem, this is what I have so far, my problem is highlighted in the
comments
private function dragToOrders(event:DragEvent):void
{
try
{
var draggedItems:Object = new Object();
draggedItems = event.dragSource.dataForFormat("items");
var n:int = orderDetailArray.length;
for (var i:int = 0; i < n; i++)
{
//The UnigueID of the dragged items will always remain the
same
//but after the first item is added to the dataProvider of
the dragTarget,
//the variables i and n will always start incremented from
the last insert,
//allowing for duplicate items and not incrementing the Qty
column
if (orderDetailArray[i].UniqueID == draggedItems.UniqueID)
{
orderDetailArray[i].Qty ++;
event.preventDefault();
return;
}
}
}
catch(ex:Error)
{
trace(ex);
trace(ex.getStackTrace());
}
}
As you can see, and as I can see while in the debugger, after the first
item is in the drag target's provider, if I try to add the same item it
will put in a duplicate entry since while the UniqueID of the item I'm
dragging will remain the same, variables i and n will start incremented
from the previous insert. For example, if i and n were 0, after the
first item, they will begin at 1. Of course this means I'm not getting
the correct index being checked when I insert a new item, my question is
how to fix it as I'm not exactly sure at this time. Thanks in advance.
Brian Ross Edwards
Tech-Connect LLC