Hi there,
I consider the task of preventing drag and drop operations on certain tree
nodes when using Tree component shipped with Flex 2 SDK to be not trivial at
all.
The internal code of Tree component is complex and not very well documented
inside the code.
I would recommend you as as starting point to create a custom event handler
for "onDragOver" event to prevent drag operation on certain tree node types,
e.g:
-------------------
private function onMyTreeDragOver(event : DragEvent) : void {
..... skipped code....
//forbid dragging on itself
if (draggedItem == hoverTarget) {
DragManager.showFeedback(DragManager.NONE);
myTree.hideDropFeedback(event);
return;
}
// forbid dragging of top level of the hierarchy
var hoverTargetParentXML : XML =
myTree.getParentItem(hoverTarget);
if (hoverTargetParentXML == null) {
DragManager.showFeedback(DragManager.NONE);
myTree.hideDropFeedback(event);
return;
}
..... skipped code....
}
-------------------
But when you start to rely on 'myTree.calculateDropIndex' to find out what
tree item is currently placed under moved draggedItem (I called this tree
item as 'hoverTarget' in the code above), you quickly become unsatisfied
with results that 'myTree.calculateDropIndex' yields.
May be I will write more on my blog on the difficulties that I had
encountered during performing the task of preventing certain drag and drop
operation with Flex 2.0.1 SDK Tree component if there will be some
considerable interest from the public.
--
Med venlig hilsen / Best regards
Andriy Panas
[EMAIL PROTECTED]