Created
June 17, 2010 16:03
-
-
Save edulan/442320 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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