Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6547763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:52:13+00:00 2026-05-25T11:52:13+00:00

I am working on the flex tree drag and drop functionality and i have

  • 0

I am working on the flex tree drag and drop functionality and i have couple of questions on it.

I have given a array collection as the data provider .Each branch(folder) and leaf(item) has a unique id.

the tree structure is some thing like this.

folder1.
      folder2.
            item1.
            item2.
            item3.
      folder3.
            item4.
            item5.
            item6.
folder4.
      item7.
      item8.
      folder5.
            item9.
            item10.
folder6.
      folder7.
      folder8.

I need to to allow the user to drag and drop an item within the folder but not outside a folder. But he can drag and drop a folder anywhere.

So the user cant drag and drop an item folder1 or folder4 or folder6 level.

I found couple examples on google…but nothing worked in my favor.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:52:14+00:00Added an answer on May 25, 2026 at 11:52 am

    Here is an example with xml data :
    I use mx_internal::_dropData property to find the real parent.

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" 
               minWidth="955" minHeight="600" 
               >
    
    
    <fx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.core.mx_internal;
            import mx.events.DragEvent;
    
    
            protected function myTree_dragDropHandler(event:DragEvent):void
            {
                /*
                Pay attention at mx_internal namespace :
                Behaviour could change in the next flex version.
                Drop data structure.
                _dropData = { 
                    parent: parent, 
                    index: index, 
                    localX: event.localX, 
                    localY: event.localY, 
                    emptyFolder: emptyFolder, 
                    rowHeight: rowHeight, 
                    rowIndex: rowNum };
                */
    
                var parent:XML = myTree.mx_internal::_dropData.parent;
                var draggedElement:XML = 
                  (event.dragSource.dataForFormat("treeItems") as Array)[0];
                if (draggedElement.name() == "item" 
                                      && draggedElement.parent() != parent) {
                    // element is an item and parent is different => can not drop                                        
                    event.preventDefault();
                    myTree.hideDropFeedback(event);
                    Alert.show("can not drop");
                }
    
                // you can also play with
                // var dropIndex:int = myTree.calculateDropIndex(event);
                // myTree.getItemIndex(dropIndex)
                // but it is a little more complicated to find 
                // the real parent because we haven't drop indicator 
                // information (child or parent position).
    
                // I did not use xml element id but it is also possible
                // parent.id != draggedElement.parent().id
    
            }
    
        ]]>
    </fx:Script>
    
    
    <fx:Declarations>
        <fx:XMLList id="treeData">
            <folder id="folder1" label="Folder 1">
                <folder id="folder2" label="Folder 2">
                    <item id="item1" label="Item 1"/>
                    <item id="item2" label="Item 2"/>
                    <item id="item3" label="Item 3"/>
                </folder>
                <folder id="folder3" label="Folder 3">
                    <item id="item4" label="Item 4"/>
                    <item id="item5" label="Item 5"/>
                </folder>
                <item id="item6" label="Item 6"/>
                <item id="item7" label="Item 7"/>
            </folder>
        </fx:XMLList>
    </fx:Declarations>
    
    <mx:Tree id="myTree" 
             width="50%" height="100%" 
             labelField="@label"
             dragEnabled="true"
             dropEnabled="true"
             dragMoveEnabled="true"
             showRoot="true" 
             dataProvider="{treeData}" 
             dragDrop="myTree_dragDropHandler(event)"/>
    
    
    </s:Application>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on Flex for last couple of months and as this
I am working on flex dasboards and charting stuff. Till now I have build
Problem solved, see below Question I'm working in Flex Builder 3 and I have
I am working on a Flex Front End at the moment, and have been
Working in Flex 3, I have a series of components being rendered on a
I have read about the wonders (and sometimes bugs) of working with flex in
I have a working Flex/Java application, but if I log out of the channelSet
Im working with a flex application that pulls data from a java class file
I'm working on a flex application and I need to call some data with
Am working on a flex project I am looking to provide some UI functionality

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.