Hopefully I can explain what I’m trying to do here and someone can tell me where my thinking is wrong. I’m creating an menu tree that takes some xml and turns it into a menu you can navigate through (I know it’s been done a million times but I need to do some custom stuff with it so I’m writing my own). I also am trying to add the ability to drag and drop the different elements around and have it reflect the changes in the xml that was used to create the menu.
For each element in the xml a corresponding menu item is created. I thought the best way to do this would be to attach a reference to each menu item movieclip of the xml element that it represents. So when I’m looping through the xml elements it looks something like this…
function createItem(element:XML){
var item:MovieClip = new MovieClip();
item.xml = element;
}
So when I’m dragging and dropping these elements each directly corresponds to an xml element. When I’m dragging I create a reference to the item being dragged called “dragItem” and when it drops I create a reference to the item it’s being dropped on called “dropItem”. Then I try to rearrange the actual xml by doing something like this…
sourceXML.insertChildBefore(dragItem[‘xml’],dropItem[‘xml’])
Where ‘sourceXML’ is the original xml object that creates the menu. This doesn’t work at all and I don’t really know enough about the new XML object to understand why. It doesn’t throw up an errors it just doesn’t work. I might not have given enough information but am I very off somewhere in my thinking on this because in theory it seems like it should work.