Return to Snippet

Revision: 30021
at August 6, 2010 04:55 by dxc381


Initial Code
package com.dxc381{
	
	//import flash classes
	import flash.display.Sprite;
	
	public class InfiniteMenu extends Sprite{
		
		private var level:int = -1;
		
		public function InfiniteMenu(menuXml){
			
			findSubs(menuXml.item);//pass in lowest level node called item
			
		}
		
		private function findSubs(subXml):void{
			
			level++;
			
			var numOfItems:int = subXml.length();
			for(var i:int = 0;i<numOfItems;i++){
				trace(level +subXml[i].@itemId);
				if(subXml[i].item.length() > 0)findSubs(subXml.item);//if there are children
			}
			
			level--;
			
		}
		
	}
	
}

Initial URL

                                

Initial Description
Run through infinite xml child nodes.

Initial Title
AS3 Recursive Function

Initial Tags
xml

Initial Language
ActionScript 3