Connecting Dynamic Lines and Nodes

I have been trying several weeks to get this to work and so far just cannot seem to figure it out. Hopefully you can offer some help.

I want to load a list of nodes from and XML file and have them dynamically displayed. This part I have managed.

I would also like to be able to dynamically draw lines connecting various movie clips based on the XML file. This is where I cannot seem to get it to work.

I also would like the nodes to be draggable but remain attached to the line.

Any suggestions or help would be greatly appreciated!!


Here is the AS code I am using:

myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(ok) {
if (ok) {
// trace('data loaded');
// trace(this.firstChild.attributes.value);
allData = this.firstChild.childNodes;
for (i=0; i<allData.length; i++) {
// trace(allData*.attributes.text);
newBut = _root.attachMovie('butTemp', 'but'+i, i);
_root.createEmptyMovieClip('mc', 'mc'+i, i);
newBut.but_txt.text = allData*.attributes.text;
newBut._x = random(700);
newBut._y = random(500); 
// set our line style
mc.lineStyle(2, 0x000000);
// draw the line based on handle locations
mc.moveTo(newBut._x, newBut._y);
mc.lineTo(newBut1._x, newBut1._y);
} else {

Here is the XML I am using:

 <?xml version="1.0" encoding="iso-8859-1"?> 
<but text="Node 1" ID="1" Parent="3"></but>
<but text="Node 2" ID="3" Parent="2"></but>
<but text="Node 3" ID="2" Parent="5"></but>
<but text="Node 4" ID="4" Parent="5"></but>
<but text="Node 5" ID="5" Parent="4"></but>
<but text="Node 6" ID="6" Parent="1"></but>
<but text="Node 7" ID="7" Parent="11"></but>
<but text="Node 8" ID="8" Parent="9"></but>
<but text="Node 9" ID="9" Parent="8"></but>
<but text="Node 10" ID="10" Parent="7"></but>
<but text="Node 11" ID="11" Parent="6"></but>
<but text="Node 12" ID="12" Parent="3"></but>