1 Reply Latest reply on Oct 9, 2007 7:39 AM by NateFlex

    Tree drag and drop not working for branches

      I'm dragging and dropping items from a TileList (which uses an Array Collection for a dataprovider) to a Tree (which uses XML) and it works when I drag an item into an existing branch of the tree and it becomes a leaf of that branch, but when I try to drag over a new branch it fails to add it. The strange thing is it works if I have the tree property showRoot set to true, but I need it to be false. Do I need to do something special when drag and dropping a new branch (aka folder)??

      Here's my dragDrop function:

      private function onDragDrop( event:DragEvent ) : void

      var dragSource:DragSource = event.dragSource;
      var dropTarget:Tree = Tree(event.currentTarget);
      var items:Array = dragSource.dataForFormat("items") as Array;
      var r:int = dropTarget.calculateDropIndex(event);
      var node:XML = dropTarget.selectedItem as XML;
      var p:*;

      p = node.parent();

      for (var i:Number=0; i < items.length; i++)

      var insertNode:XML = <node />;
      insertNode.@label = items[ i ].label;
      insertNode.@data = items[ i ].data;
      insertNode.@icon = items[ i ].icon;

      MyTree.dataDescriptor.addChildAt(p, insertNode, r);