I am rather new to AS and have been trying to work through this for several weeks now. I thought I had it figured out only to find out that I forgot a MC may be linked to several MCs.
What I am trying to do is create a “network” type layout with nodes and connecting lines. Similar to this but not as complex. http://www.quasimondo.com/archives/flashconnection.html
The data is pulled from an XML document
<?xml version="1.0" encoding="iso-8859-1"?>
<network>
<nodes>
<but text="Node 1" ID="1"></but>
<but text="Node 2" ID="2"></but>
<but text="Node 3" ID="3"></but>
<but text="Node 4" ID="4"></but>
<but text="Node 5" ID="5"></but>
</nodes>
<links>
<link fromID="1" toID="2"></link>
<link fromID="1" toID="3"></link>
<link fromID="1" toID="4"></link>
<link fromID="1" toID="5"></link>
<link fromID="2" toID="4"></link>
<link fromID="3" toID="5"></link>
</links>
</network>
I can get it to display the nodes but am unable to draw the lines to connect them.
Here is the AS I am using to display the nodes.
//This section loades the nodes from the xml document
this.dataArray = new Array();
for (var ID=0;ID < dataSrc.length;ID++){
if (dataSrc[ID] != undefined){
var thisBut = _root['but'+ID];
var mc = _root['mc'+ID];
}
}
myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(ok) {
if (ok) {
allData = this.firstChild.firstChild.childNodes;
for (i=0; i<allData.length; i++) {
nodeID = Number(allData*.attributes.ID);
_level0.dataArray[nodeID] = new Object();
var thisNodeObj = _level0.dataArray[nodeID];
thisNodeObj.text = allData*.attributes.text;
thisNodeObj.prnt = Number(allData*.attributes.Parent);
// can't create two clips at same depth
var newBut = _root.attachMovie('butTemp', 'but'+nodeID,
(nodeID*2)+1);
_root.createEmptyMovieClip( 'mc'+nodeID, nodeID*2);
newBut.but_txt.text = thisNodeObj.text;
newBut._x = random(700);
newBut._y = random(500);
}
} else {
trace("error");
}
};
myXML.load('node_link.xml');
If any one can help it would be greatly appreciated. I have a file that I did get to draw the lines between the nodes but it doesn’t allow a node to connect to more than one parent node. Here is the file that I did get to work:http://www.wytchwolf.com/xml_nodes.zip
I will attach the files I am working on now to connect multiple nodes as well. Again any help would be greatly apprecated as I said I am rather new to all this and my hair is already getting thinner.