// enables drag and drop within the tree
tree.draggable = true;
// attaches two tree instances to the stage
attachMovie("advancedTree", "tree_1", 0);
attachMovie("advancedTree", "tree_2", 1);
// enables tree_1 and tree_2 to have draggable nodes internally
tree_1.draggable = true;
tree_2.draggable = true;
// enables tree_1 and tree_2 to receive nodes from other trees
DragManager.addListener(tree_1, "TreeNode", "onDragNode", "onDropNode", "external");
DragManager.addListener(tree_2, "TreeNode", "onDragNode", "onDropNode", "external");
// attaches a tree instance to the stage
attachMovie("asdvancedTree", "tree", 0);
// enables tree to have draggable nodes internally
tree.draggable = true;
// overrides the calling of the internal method when a node is dropped so that a developer-defined method may be called
// the onDragNode method is NOT overridden, as in this instance the default functionality is desired
DragManager.addListener(tree, "TreeNode", "onDragNode", "onValidateDrop", "internal");
import com.flashloaded.ui.controls.lists.TreeNode;
// a new method that will be called when a node is dropped internally in the tree
// NOTE: this method represents exactly what happens internally by default
// NOTE: you would only override this if you wanted to change the default functionality
tree.onValidateDrop = function(
draggedClip:MovieClip, // clip being dragged on stage
node:TreeNode, // the TreeNode instance being dragged and represented by the draggedClip
position:Object, // an object with x and y properties holding the global position of the draggedClip
):Void {
var scrollPos:Object = this.getScrollPosition(); // the current position of the scrollbars
this.removeDropLine(); // removes visual cue from tree
this.deselectNodes(); // deselects all nodes in tree
var newNode:TreeNode = node.copyNode(); // copies dragged node
this.addNodeAt(this.dropInfo.node, newNode, this.dropInfo.index); // adds copied node to dropped position
node.remove(); // removes dragged node
this.refresh(); // refreshes view of tree
this.setScrollPosition(scrollPos.x, scrollPos.y); // puts scrollbars back to position before the refresh
};