Are you using a custom event?
And if so, did you implement the clone method?

2009/1/19 claudiu ursica <the_bran...@yahoo.com>

>   Hi Alex,
> I can move simple leafs from the root under a folder with no custom
> handlers, if the folder is open. However the thing is that I need to just
> put (maybe just copy not move) the item let's say for argument sake "<node
> label="Sent"/>" under "Inbox" folder. I cannot do that unless the "sent"
> is under some folder and move it with the folder, because otherwise the
> DragSource seeems to return an item but I cannot get the data from that
> item. So I end up dropping an empty item. However as said before If I
> move/copy a folder with items around it works fine ... The same happends
> with the drag complete handler, for just one item the drags source traces
> out to blank event though the length is 1.
>
> Claudiu
>
> ------------------------------
> *From:* Alex Harui <aha...@adobe.com>
> *To:* "flexcoders@yahoogroups.com" <flexcoders@yahoogroups.com>
> *Sent:* Monday, January 19, 2009 7:47:53 AM
> *Subject:* RE: [flexcoders] Drag And Drop Tree
>
>   Setting breakpoints in drag/drop generally doesn't work because you tend
> to release the mouse in order to dig through the debugging info and when you
> resume the drag is cancelled.
>
>
>
> Remove the custom drag event handlers and try with simple data and see if
> it works.  We definitely tested drag/drop in Tree so basic cases work.  One
> trick for Tree is that what happens on drop is different than in List.  The
> node is removed before it is added in Tree, and sometimes that is done in
> dragComplete handler instead of dragDropHandler
>
>
>
> *From:* flexcod...@yahoogro ups.com [mailto:flexcoders@ yahoogroups. com]
> *On Behalf Of *Claudiu Ursica
> *Sent:* Sunday, January 18, 2009 9:59 AM
> *To:* flexcod...@yahoogro ups.com
>
> *Subject:* [flexcoders] Drag And Drop Tree
>
>
>
> Hi I'm trying to implement the drag and drop functionality inside a
> tree, dragging and dropping inside the same tree. However It seems
> that I cannot drag and drop leaf nodes... When I handle enterDrag
> event the item seems to be appearing only at debug time and gets lost
> after that...
>
> here is the code..
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe. com/2006/ 
> mxml<http://www.adobe.com/2006/mxml>
> "
> layout="absolute">
>
> <mx:Script>
> <![CDATA[
> import mx.events.DragEvent ;
> import mx.managers. DragManager;
> import mx.core.UIComponent ;
> import mx.core.DragSource;
>
>
>
> private function onDragEnter( event : DragEvent) : void
> {
> var items : Array = event.dragSource. dataForFormat("treeItems") as
> Array;
>
> trace("items ", items);
> //this only shows data for branches
>
> //if I try drag drop a leaf like spam for
> //instance I can see the node only when debugginh and when
> resuming the data is gone
> //when resuming even though the length is 1
> }
>
> /**
> * The dragDrop event is dispatched when the mouse is released.
> * The Tree can still ignore the drop here
> */
> private function onDragDrop(event : DragEvent) : void
> {
> var ds : DragSource = event.dragSource;
>
> var items : Array = ds.dataForFormat("treeItems") as Array;
> trace("items ", items);
> //this display actually the drop node instead of the dragsource
>
> var dropTarget : Tree = Tree(event.currentT arget);
>
> var selectedIndex : int = myTree.calculateDro pIndex(event) ;
>
> myTree.selectedInde x = selectedIndex;
>
> var node : XML = myTree.selectedItem as XML;
> var dropParent : *;
>
> // if the selected node has children
> // then add the items at the beginning
> if(myTree.dataDescr iptor.hasChildre n(node))
> {
> dropParent = node;
> selectedIndex = 0;
> }
> else
> {
> dropParent = node.parent( );
> }
>
> // taking all of the items in the DragSouce, insert them into the
> // tree using parent pointer.
> // taking all of the items in the DragSouce, insert them into the
> // tree using parent pointer.
> var xml : XML = new XML(items);
> var sucess : Boolean =
> myTree.dataDescript or.addChildAt( dropParent, xml, selectedIndex) ;
>
>
> //trace(sucess) ;
>
> }
>
>
>
> ]]>
> </mx:Script>
>
> <mx:Tree id="myTree"
> width="300"
> height="100%"
> labelField="@label"
> showRoot="false"
> dataProvider="{treeData}"
> borderStyle="none"
> dragEnabled="true"
> dragMoveEnabled="true"
> dropEnabled="true"
> dragEnter="onDragEnter( event)"
> dragDrop="onDragDrop(event)">
> </mx:Tree>
>
> <mx:XMLList id="treeData">
> <node label="Mail Box">
> <node label="Inbox">
> <node label="Marketing"/>
> <node label="Product Management"/>
> <node label="Personal"/>
> </node>
> <node label="Inbox">
> <node label="Marketing"/>
> <node label="Product Management"/>
> <node label="Personal"/>
> </node>
> <node label="Inbox">
> <node label="Marketing"/>
> <node label="Product Management"/>
> <node label="Personal"/>
> </node>
> <node label="Outbox">
> <node label="Professional"/>
> <node label="Personal"/>
> <node label="Inbox">
> <node label="Marketing"/>
> <node label="Product Management"/>
> </node>
> <node label="Personal"/>
> </node>
> <node label="De mutat">
> <node label="Unu"/>
> <node label="Doi"/>
> <node label="DoiUnu">
> <node label="DoiUnuUnu"/>
> <node label="DoiUNuDoi"/>
> </node>
> <node label="Trei"/>
> </node>
> <node label="Spamu"/>
> <node label="Sent"/>
> <node label="Movable"/>
> </node>
> </mx:XMLList>
>
> </mx:Application>
>
> so the code seems to be working when drag and dropping an folder but
> not when dropping a leaf, I get a new Item with no label.
> I have searched the archives for something similar and found only the
> same issue posted twice by 2 different guys and no answers. So I
> thought I'll have better luck...
>
> TIA,
> Claudiu
>
>
>  
>

Reply via email to