How to determine the end of rucursive loops
July 6, 2005 12:01 AM
Subscribe
In Flash how do i determine the end of a bunch of recursive loops through an xml document of unknown size? [mi]
I havn't written the code yet - but i can show the flow:
xml.onLoad=generateMenu(xml);
function generateMenu(xmlParent){
for(x=0;x<xmlParent.childNodes.length;x++){
make menuItem from xmlParent.childNode[x];
if(xmlParent.childNode[x].hasChild){
generateMenu(xmlParent.childNode[x].);
}
}
}
Not knowing the extent of xml - that is how many childrens childrens children etc. - how do i determine when the generateMenu has finished looping in all its instances?
posted by FidelDonson to technology (8 comments total)
It's just a recursive tree traversal (in your example, a pre-order traversal).
posted by orthogonality at 1:03 AM on July 6, 2005