Sorting items

I’m working on an interactive that allows the user to drag items and stack them into a pile. Once in the pile, I need to make it so the user is able to view an item by clicking on it, which will bring it to the front of the pile. After it is brought to the front of the pile, the other stacked items need to shift upwards to fill the gap created when the item was removed from the pile and placed at the front.

The attached swf visually shows what I’m trying to achieve.

I’m pretty competent in drag and drop stuff, but my main prob is enabling the pieces to all reposition themselves to fill the gap. I’m sure I’ve seen menu systems and/or card stacking games that are similar, so I’m sure it’s achieveable, I just don’t know how to do it myself, or where to find a tutorial on doing such a thing. Thanks for any help you can give :slight_smile: