Flex 3 List Drag & Drop Example

Published on 11 January 2010 by Wesley Gooch in Adobe Flex

3

Recently, I needed to develop a drag-and-drop feature between two lists using Adobe Flex 3. As a learning experience, I built an example application to experiment with the best approach to how this is done. This post will briefly describe my solution with the source code included.

I named the example application the Dual List Manager.

Dual List Manager Example Application

Flex Drag & Drop Basics

The List component already supports drag and drop by default, so at a minimum, all one has to do is enable dragEnabled, dragMoveEnabled, dropEnabled in MXML and supply a data provider. However, for most real world scenarios we need to handle a lot more then that. Below is the list component that I used of which I wrapped in the ListManagerPanel.mxml class. Take a look at the example and it’s source code and take special care to look at the ListManagerPanel class. Two instances of that class support dragging and dropping between their lists.

<mx:List id="itemsList"
    width="100%" height="100%"
    allowMultipleSelection="true"
    change="validateState()"
    dataProvider="{listItems}"
    itemDoubleClick="editItem()"
    doubleClickEnabled="true"
    dragComplete="validateState()"
    dragEnabled="true"
    dragMoveEnabled="true"
    dropEnabled="true">
</mx:List>

I won’t go into detail explaining the inner workings of the example application but feel free to use the source code as inspiration for your own work.

If you have questions don’t be afraid to ask.

Additional Online Resources

3 Responses to “Flex 3 List Drag & Drop Example”

  1. vasil says:

    Hi U create very simple and beautiful app! thank’s it’s reaaly amazing…i have 1 problem: “Problem finding external stylesheet: /assets/styles.css”…Thanks!)

  2. Wesley Gooch says:

    Vasil,

    Thanks for the comment. I didn’t include the styles.css and theme because they include graphics, icons, and fonts that I am not licensed to give away freely. As such, I can’t include the theme. Sorry about that. If you would like some inspiration on theming a Flex application similar to what I did check out these links:

    http://www.adobe.com/devnet/air/flex/articles/salesbuilder_v2demo.html
    http://coenraets.org/blog/2009/04/new-version-of-salesbuilder-with-ribbit-integration-source-code-available/

    Cheers,
    Wes

  3. vasil says:

    Wesley Gooch, thanks for fast answer) thanks for links…tonight will create app similar your’s. See you graph, very nice. Sorry for english) Hope soon we don’t need languge for share ideas and technics

Leave a Reply