     Here’s one way to supply drag-and-drop to a tree component. This traps the mouseup and mousedown events. It’s not elegant and it hasn’t been thoroughly tested; and performance tests have not been made, but it works so far
    .
    The problem with the Flash tree component is that it does not assign the selectedItem property of the tree component on the mousedown event. So this means that trapping the mousedown event when it occurs in the tree component will give you an undefined selectedItem property. But, what you can do is trap the first mouse move event after the mousedown event in the tree, from which the selectedItem property will return a valid node.
    To drag and drop a node from a source tree to a destination tree, in order of events, this is what is being done:
    1. Set two flags (call them isTreeMouseDown and isMouseMove) to false.
    2. Set an XMLNode type variable (call it curNode) to null.
    3. Initialize the nodes on the source tree component (call it sourceTree).
    4. Initialize the root node on the destination tree component (call it destTree).
    5. On a mousedown event in the tree control, set isTreeMouseDown and isMouseMove to true.
    6. On a mousemove event, if the isTreeMouseDown flag is true, set curNode to tree.SelectedItem and set isMouseMove to false. This saves the node to be dropped and makes sure that another node is not selected on subsequent move events.
    7. Trap the mouseup event. It it occurs in destTree, add the node to the destTree. Whether it is in the destTree or not, set isTreeMouseDown and IsMouseMove to false.
    Here’s the code skeleton:
    //initialize sourceTree
    //initialize destTree
    var mouseListener:Object = new Object();
    var isTreeMouseDown:Boolean = false;
    var isMouseMove:Boolean = false;
    var curNode:XMLNode;
    mouseListener.onMouseDown = function() {
    if (_xmouse > sourceTree.left and _xmouse < sourceTree.left + sourceTree.width
    and _ymouse > sourceTree.top and _ymouse < sourceTree.top + sourceTree.height){
    isTreeMouseDown = true;
    isMouseMove = true;
    }
    };
    mouseListener.onMouseUp = function() {
    if (isTreeMouseDown and _xmouse > destTree.left and _xmouse < destTree.left + destTree.width and _ymouse > destTree.top and _ymouse < destTree.top + destTree.height){
    destTreeDP.firstChild.appendChild(curNode);
    }

    isTreeMouseDown = false;
    };
    mouseListener.onMouseMove = function(){
    if (isMouseMove) {
    curNode = sourceTree.selectedItem;
    }
    isMouseMove = false;
    }

    A couple of notes: this is the bare bones. Details like updating the destination tree to reflect the node additions, removing the node (if desired) from the source tree, and performance issues (if present) are not covered. 

chrisworth said on Feb 9, 2005 at 2:53 PM :

    The previous comment lacked some things. First, it describes how to drag-and-drop from a source tree to a destination tree. Second, the variable used, destTreeDP is the data provider for the tree. The code to set up the data provider is two lines:
    var destTreeDP: XML = new XML(); //declare and initialize
    //add the root node to destTreeDP
    destTree.dataProvider = destTreeDP; //assign the data provider as the
    //destTree data provider 

 