How do i Drag and drop From one tree to another and vise versa?

I have two tree structures and i'm trying to drag a leaf of a branch from one tree to another and vise versa. i'm using flex 3 to code it. I'm also trying to put a prevention on dropping a leaf of one tree from being dropped inside a branch of another tree. Anything that is dragged over to another tree should be placed as a dangling node in that tree. Please share this code and help me find a solution.
<?xml version="1.0" encoding="utf-8"?><mx:Application 
xmlns:mx="
http://www.adobe.com/2006/mxml" xmlns:comp="
com.adobe.flex.extras.controls.*" initialize="data2
new
ArrayCollection(countries);"layout="
absolute"verticalAlign="
middle" backgroundColor="white" height="
551">
<mx:Script>
<![CDATA[
importmx.events.FlexEvent; 
importmx.collections.ArrayCollection; 
importmx.controls.Alert; 
importmx.events.DragEvent; 
importmx.managers.DragManager;  
importmx.core.DragSource;  
importmx.core.UIComponent;  
importmx.controls.Tree;  
// data provider for role name[
Bindable] private vardata2: ArrayCollection; 
// variable to store the node that is dragged from a tree 
private var draggedItemOfAccessTree:XML = null;  
private var draggedItemOfExclusionTree:XML = null; 
private var dragItemAccess:DisplayObject =null; 
private var dragItemExclusion:DisplayObject =null; 
// Array to store the Role list[
Bindable]public varcountries: Array = [{id: 0, name:
"Role 1"},{id: 1, name:
"Role 2"},{id: 2, name:
"Role 3"},{id: 3, name:
"Role 4"},{id: 4, name:
"Role 5"},{id: 5, name:
"Role 6"},{id: 6, name:
"Role 7"},{id: 7, name:
"Role 8"},{id: 8, name:
"Role 9"},{id: 9, name:
"Role 10"},{id: 10,name:
"Role 11"} 
// this event is called when we begin dragging a node in a tree 
private function onAccessListDragEnter( event:DragEvent ) : void{
event.preventDefault();
vards1:DragSource = event.dragSource;  
var items1:Array = ds1.dataForFormat("treeItems") asArray; 
if (items1 != null && items1.length > 0 && (items1[0] isXML)){
draggedItemOfAccessTree = items1[0];
dragItemAccess = items1[0]
asDisplayObject;}
DragManager.acceptDragDrop(UIComponent(event.currentTarget));
private function onExclusionListDragEnter( event:DragEvent ) : void{
event.preventDefault();
vards2:DragSource = event.dragSource;  
var items2:Array = ds2.dataForFormat("treeItems") asArray; 
if (items2 != null && items2.length > 0 && (items2[0] isXML)){
draggedItemOfExclusionTree = items2[0];
dragItemExclusion =items2[0]
asDisplayObject;}
DragManager.acceptDragDrop(UIComponent(event.currentTarget));
private function onAccessListDragOver( event:DragEvent ) : void{
event.preventDefault();
varvar1:Number = AccessTree.selectedIndex; 
varvar2:Number = ExclusionTree.calculateDropIndex(event);  
var node1:XML = AccessTree.selectedItem asXML;  
var node2:XML = ExclusionTree.calculateDropIndex(event) asXML;  
//restrict drag & drop to nodes within same parent  
if(draggedItemOfAccessTree.parent() == node1.parent() || draggedItemOfAccessTree.parent() != node1.parent()){
DragManager.showFeedback(DragManager.NONE);
//return; }
elseDragManager.showFeedback(DragManager.MOVE);
private function onExclusionListDragOver( event:DragEvent ) : void{
event.preventDefault();
varvar1:Number = ExclusionTree.selectedIndex;  
varvar2:Number = AccessTree.calculateDropIndex(event); 
var node1:XML = AccessTree.calculateDropIndex(event) asXML;  
var node2:XML = ExclusionTree.selectedItem asXML;  
//restrict drag & drop to nodes within same parent  
if( draggedItemOfExclusionTree.parent() == node2.parent() || draggedItemOfExclusionTree.parent() != node2.parent()){
DragManager.showFeedback(DragManager.NONE);
// return; }
elseDragManager.showFeedback(DragManager.MOVE);
private function onAccessListDragDrop( event:DragEvent ) : void{
event.preventDefault();
varSindex:Number = AccessTree.selectedIndex; 
varEindex:Number= ExclusionTree.calculateDropIndex(event);  
var Enode:XML = ExclusionTree.selectedItem asXML;  
var Anode:XML = AccessTree.selectedItem asXML; 
if((draggedItemOfAccessTree.parent() != Anode.parent()) ){
AccessTree.removeChildAt(Sindex);
ExclusionTree.addChildAt(dragItemAccess , Eindex);
// AccessTree.rdataDescriptor.removeChildAt(Anode.parent(),draggedItemOfAccessTree,Sindex);  
//ExclusionTree.dataDescriptor.addChildAt(Enode.parent(),draggedItemOfAccessTree,Eindex); }
private function onExclusionListDragDrop( event:DragEvent ) : void{
event.preventDefault();
varEindex:Number = ExclusionTree.selectedIndex; 
varSindex:Number = AccessTree.calculateDropIndex(event);  
var Anode:XML = AccessTree.selectedItem asXML;  
var Enode:XML = ExclusionTree.selectedItem asXML; 
if((draggedItemOfExclusionTree.parent() != Enode.parent()) ){
ExclusionTree.removeChildAt(Eindex);
AccessTree.addChildAt(dragItemExclusion, Sindex);
// ExclusionTree.dataDescriptor.removeChildAt(Enode.parent(),draggedItemOfExclusionTree,Eind ex);  
// AccessTree.dataDescriptor.addChildAt(Anode.parent(),draggedItemOfExclusionTree,Eindex); }
private function onDragComplete( event:DragEvent ) : void

Yes, I have set dragEnabled and dropEnabled to true. I trying to put restriction on dropping the node(aka leaf) of 1st free tree inside the branch(aka folder) of the 2nd tree. If something is dragged from tree1, it should be dropped only on tree2  i.e., dragged node should be appended at the end of tree2 and not inside nay of the branches of tree2. This functionality should work on both the trees. I'll be glad if u can provide the solution.

Similar Messages

  • Upgarded to PE 13 - How do I drag an image from one screen to another (using 2 monitors)

    upgarded to PE 13 - How do I drag an image from one screen to another (using 2 monitors)

    upgarded to PE 13 - How do I drag an image from one screen to another (using 2 monitors)

  • I am trying to drag and drop one page of a .pdf into another .pdf in Acrobat Reader.  I used to be able to drag and drop from one .pdf to another.

    I am trying to drag and drop one page of a .pdf into another .pdf in Acrobat Reader.  I used to be able to drag and drop from one .pdf to another.

    If you could drag and drop pages before, it wasn't in Reader. You no doubt had Adobe Acrobat (Pro or Standard) which shouldn't be confused with Adobe Acrobat Reader. They recently added Acrobat to the name of Adobe Reader so the confusion about which product you had and/or have is understandable.

  • Why doesn't the original document I'm dragging and dropping from one folder to another move?

    Why doesn't the original document I'm dragging and dropping from one folder to another move?
    What's happening is the computer is creating a duplicte of the document and placing it in the new location with a new creation date.  The original document I wanted to drag and drop into a new location remains where it started as the "original" document and the new copy has this little arrow protruding up from the lower left of its icon.
    At first I thought it was an alias, but it's a copy of the document I thought I was dragging and dropping.
    What gives here?
    Steve

    That arrow indicates it is a linik to the original, though. This happens if you wish to drag files, for which you do not have permissions to do this operation, e.g. from Library or System folder. I am pretty sure you do not accomplish this operation from/to folders like Desktop or Documents; if so, there is a problem with your system.

  • How do I transfer my bookmarks from one computer to another? I have Firefox Home on my phone and I can get them there, but I want to have the same bookmarks on my home computer as I do on my work computer.

    How do I transfer my bookmarks from one computer to another? I have Firefox Home on my phone and I can get them there, but I want to have the same bookmarks on my home computer as I do on my work computer. If I have a user name then where do I sign into Firefox, it should be that easy but I can't seem to figure it out.

    Hey susanneyes,
    Sounds like you want to set up Firefox Sync. This will allow you to keep all of your instances of Firefox synchronized. Just follow the steps in [https://support.mozilla.com/en-US/kb/what-firefox-sync?s=sync&r=0&as=s this article] and you'll be set.
    Hopefully this helps!

  • How do you transfer Apple IDs from one ipad to another iPad?  I got the new ipad and gave my ipad 2 to my wife who had the first version and now I can't get my Apple ID off so she can use her Apple ID.

    how do you transfer Apple IDs from one ipad to another iPad?  I got the new ipad and gave my ipad 2 to my wife who had the first version and now I can't get my Apple ID off so she can use her Apple ID.

    You don't transfer Apple ID's from one device to another one. You sign out in the settings, )the App Store and iTunes if necessary) and then sign in with the other ID.
    Settings>iTunes & App Stores>Apple ID>Sign out. Them sign in with the other ID. You can sign out of the app store and iTunes as well by going to the featured Atab in the App Store and the music tab in iTunes, swipe to the bottom and access the Apple ID in there.
    You should have erased the iOad before you gave it to her in Settings>General>Reset>Erase all content and settings. That way she could set up the iPad as new with her own Apple ID.
    Be aware of the fact that if you use each others ID's in order to download past purchased content to your own iPads, you will lock yourself out of your own ID as you will have associated your iPad with the other person's Apple ID.
    In other words, if you sign into your wife's ID on your iPad so that you can download an app or an album so that you don't have to pay for it again, you will lock yourself out of your Apple ID for 90 days.

  • How do I move an object from one photo to another and then change the scene, i.e.  winter to sum?

    How do I move an object from one photo to another and then change the scene, i.e.  winter to summer?

    OK.
    Open the picture with the new scene. This will be your canvas.
    Open the picture with object A, select it with one of the selection tools, go to Edit>copy
    Go back to the new scene/canvas, Go to Edit>paste
    Repeat for object B
    Use the move tool to position A & B, each on its own layer. Use the corner handles of the bounding box to resize, if necessary
    You should have 3 layers: Background layer, and the 2 layers with A & B
    Note: It's best if the resolution of the 3 picture files is the same value.

  • Photoshop: how to drag a layer from one tab to another?

    Hello, I am trying to drag a layer from one tab to another in Photoshop and I was able to do this less than 1/2 hour ago and now it will not drag. I have closed the program, restarted my computer, everything and it will not drag. What is wrong???

    Does this work for you?
    Document A - left click to select the layer to be copied, then Layer command in the menu bar (or right click in the Layers panel) > Duplicate Layer
    In the Duplicate Layer dialogue box, Destination: Document, select the open file to which you want to copy the layer from the dropdown menu
    Click OK

  • I have no problems copying iMovie Events from one Mac to another, however, how can I copy iMovie Projects from one Mac to another?

    I have no problems copying iMovie Events from one Mac to another, however, how can I copy iMovie Projects from one Mac to another?  Any help will be appreciated.  Thank you.

    This should give you some good insight, I'd probably store them on an External HD on the old machine and then just drag and drop to the new machine.
    https://discussions.apple.com/docs/DOC-4141

  • IMovie 10 - how do I move an event from one library to another?

    Greetings,
    I have updated all of my projects and events from iMovie 9 to iMovie 10.0.1. They now all sit in different libraries on different external HDDs.
    How do I move an event from one library to another library in iMovie 10? How do I copy an event from one library to another library in iMovie 10?
    Thanks,
    John

    Simply drag and drop from one library to another.  See:  http://help.apple.com/imovie/mac/10.0/#mov3fa25bae7
    Geoff.

  • How can I move a photo from one project to another

    How can I move a photo from one project to another without creating a duplicate so I have the same photo in two projects.
    I seems to me in the past when I moved the photo from project 1 to project 2, I would get a number showing the # of photos being moved and you could drag and drop in the 2nd folder and the photos would disappear from project 1 and show up in project 2. is there a setting I am missing.  Now when I drag and drop the photo no red # shows up and the photo stays in project 1 and also shows up in project 2 apparently creating a duplicate.
    Any suggestion?

    Now when I drag and drop the photo no red # shows up and the photo stays in project 1 and also shows up in project 2 apparently creating a duplicate.
    The projects are the basic containers.  Each image and all its versions are in exactly one project.
    You can use an image in many albums, without duplicating it, also in many products like books, screensaver, slideshows.  But the projects are the basic structure of the library and you cannot have the same image in two different project, without duplicating it by storing the same original image files twice. Use albums to organize your library thematically.
    Sorry, I misread your question.   Dragging an image file between projects should move the image and all its versions to the other project.  Aperture should only duplicate the image, if you hold down the alt/options key while dragging and move the image otherwise.
    Which Aperture version are you using? And which MacOS X version?  Is your profile signature "MacBook Pro with Retina display, Mac OS 9.2.x, Aperture 3.5.1" still valid?
    In Aperture 3.6 on MacOS X 10.10.1 dragging between projects is still working as expected:

  • Is there a way to do a mass contacts drop from one mac to another mac?

    Is there a way to do a mass contacts drop from one mac to another? I've been trying to find our how to do one without any sucess other than airdropping them one at a time and that's not productive.

    Welcome to the Apple community Confousticated.
    Show all contacts, select the first in the list, shift-click the last in the list (this selects them all) drag to your desktop, transfer the file to the other Mac and double click it.

  • How do i move an app from one page to another

    how do i move an app from one page to another? When I upgraded to the latest software on my 4s, the camera went to the last page rather than remaining on the home page

    What Rudegar says is true, but it's a lot easier to rearrange icons in iTunes:
    Connect your phone and open iTunes. 
    Click on the Apps tab. 
    You will see your home screen in the main window, with the other screens in a scrollable column on the right. Scroll down and click on the last page to put it in main window. 
    Now scroll the column so the home page is visible on the right.
    Click on the Camera and drag it onto the home page at the right. 
    Be careful not to accidentally insert it into another app, thereby creating a group.

  • How do I copy Secure Notes from one computer to another in Lion?

    How do I copy Secure Notes from one computer to another?
    Keychain sync is no longer available

    Move the entire keychain to any location on the new computer and double-click it. You can then drag the notes from one keychain to the other.
    (64538)

  • How we can get the values  from one screen to another screen?

    hi guru's.
         how we can get the values  from one screen to another screen?
              we get values where cusor is placed but in my requirement i want to get to field values from one screen to another screen.
    regards.
      satheesh.

    Just think of dynpros as windows into the global memory of your program... so if you want the value of a field on dynpro 1234 to appear on dynpro 2345, then just pop the value into a global variable (i.e. one defined in your top include), and you will be able to see it in your second dynpro (assuming you make the field formats etc the same on both screens!).

Maybe you are looking for