The DropContext class provides the context in which the dropping of a node occurs. You can use this to perform your own drag and drop validation on the tree. You do not ever instantiate this class, but instead retrieve a reference through the dropContext property of the AdvancedTree.
| Property Name | Access | Class | Description | Value |
| position | public | uint | The position for the drop in relation to the node on which it was dropped. This will be a constant on the class, NULL, OVER_NODE or BETWEEN_NODES. | |
| node | public | TreeNode | The node onto which the dragged node was dropped. | |
| index | public | uint | The index position in the childnodes of the node onto which the dragged node was dropped at which the dropped node will be inserted. | |
| NULL | static public | uint | This constant value specifies that there was no node onto which the dragged node was dropped. This should be viewed as an error condition. | 0 |
| OVER_NODE | static public | uint | This constant value specifies that the dragged node was dropped directly onto the node. | 1 |
| BETWEEN_NODES | static public | uint | This constant value specifies that the dragged node was dropped in between child nodes of the node. | 2 |
DropContext is found in the com.flashloaded.ui.tree.drag package. An example of its use follows:
private function onDropPrecommit(event:TreeEvent):void {
var dropContext:DropContext = _tree.dropContext;
if (dropContext.position != DropContext.NULL) {
// always add dropped nodes to end of childnodes
if (dropContext.index > 0) {
var draggedNode:TreeNode = event.node;
var droppedOnNode:TreeNode = dropContext.node;
event.preventDefault();
var copiedNode:TreeNode = draggedNode.copy();
_tree.removeNode(draggedNode);
droppedOnNode.addNode(copiedNode);
}
}
}