Here is an example to get you started.
Tracy
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
width="400" height="600" marginLeft="6" marginRight="6" >
<mx:Script>
<![CDATA[
import mx.managers.DragManager;
function doDragEnter(event) {
event.handled = true;
}
function doDragExit(event) {
event.target.hideDropFeedback();
}
function doDragOver(event) {
event.target.showDropFeedback();
if (Key.isDown(Key.CONTROL))
event.action = DragManager.COPY;
else if (Key.isDown(Key.SHIFT))
event.action = DragManager.LINK;
else
event.action = DragManager.MOVE;
}
function doDragDrop(event) {
// Since the drag is over, remove visual feedback from
the target.
doDragExit(event);
var dragItems =
event.dragSource.dataForFormat("treeItems");
var dest = event.target;
//var dropLoc =
dest.getDisplayIndex(dest.getTreeNodeAt(0));
var dropLoc = dest.getDropLocation();
var destParentNode = dest.getDropParent();
for(var i in dest){
trace(i + ": " + dest[i]);
}
var dropNode = dest.getNodeDisplayedAt(dropLoc);
//var relDropLoc = dest.getDisplayIndex(dropNode);
//dest.clearSelected();
for (var i = dragItems.length - 1; i >= 0; i--)
{
//trace(dropLoc)
//trace(dropNode);
//trace(relDropLoc);
//trace(dragItems[i]);
destParentNode.addTreeNodeAt(dropLoc,
dragItems[i]);
//dest.selectItem(dropLoc, true);
}
}
function initApp() {
firstList.dataProvider = treeDP;
//secondList.dataProvider = [];
}
function doDragComplete(event)
{
var dragItems =
event.dragSource.dataForFormat("source").selectedItems;
trace(event.dragSource.dataForFormat("source").selectedItems);
var counter = dragItems.length;
for (var i=0;i<counter;i++)
{
var item = dragItems[i];
trace(item);
item.removeTreeNode();
}
}
]]>
</mx:Script>
<mx:XML id="treeDP">
<node label="Mail">
<node label="Inbox"/>
<node label="Personal Folder">
<node label="Demo" isBranch="true" />
<node label="Personal" isBranch="true"/>
<node label="Saved Mail" isBranch="true"/>
<node label="bar" isBranch="true" />
</node>
<node label="Sent" isBranch="true" />
<node label="Trash"/>
</node>
<node label="Calendar"/>
</mx:XML>
<mx:Label text="Drag items within the list" />
<mx:HBox marginBottom="6">
<mx:Tree id="firstList" width="100%" height="100%"
dragEnabled="true"
multipleSelection="true"
initialize="initApp()"
dragComplete="doDragComplete(event)"
dragEnter="doDragEnter(event)"
dragExit="doDragExit(event);"
dragOver="doDragOver(event);"
dragDrop="doDragDrop(event)"/>
</mx:HBox>
</mx:Application>
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Danger
Sent: Thursday, January 19, 2006 2:40 AM
To: [email protected]
Subject: Re: [flexcoders] Drag and Drop in Tree Componet
Good Luck~
http://www.sephiroth.it/file_detail.php?id=133
On 1/19/06, kjlinboomer <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I am developing a tree component with drag and drop dunctionality
> within
> itself (ie -- if a drag a leaf from one branch to another). Can
> somebody point me in the right direction of a tutorial or some online
> examples.
>
> Thanks!
>
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ:
> http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.com
>
>
> ________________________________
> YAHOO! GROUPS LINKS
>
> Visit your group "flexcoders" on the web.
>
> To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> ________________________________
>
--
Danger's Flash Blog
http://www.dengjie.com
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/