Skip to content

Instantly share code, notes, and snippets.

@edulan
Created June 17, 2010 16:03
Show Gist options
  • Save edulan/442320 to your computer and use it in GitHub Desktop.
Save edulan/442320 to your computer and use it in GitHub Desktop.
function iterComponents() {
var root:Object = arguments[0];
var f:Function = arguments[1];
var cache:Object = arguments[2];
if(!cache)
cache = new Object(); // initialize cache
cache[root] = true; // mark as visited
for(var obj in root) {
// visit unvisited components
if(!cache[root[obj]]) {
f(root[obj]);
iterComponents(root[obj], f, cache);
}
}
}
iterComponents(_level0, function(o){ trace(o) });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment