Skip to content

Instantly share code, notes, and snippets.

@rjungemann
Created December 16, 2010 23:45
Show Gist options
  • Save rjungemann/744235 to your computer and use it in GitHub Desktop.
Save rjungemann/744235 to your computer and use it in GitHub Desktop.
traverses a tree of DisplayObjects, calling the callback function on each
// traverses a tree of DisplayObjects, calling the callback function on each
function descendClips(clip, callback) {
callback(clip);
for(var i = 0; i < clip.numChildren; i++) {
var child = clip.getChildAt(i);
try { descendClips(child, callback); } catch(e) {}
}
}
// whatever function is specified as the second argument gets called for each clip
descendClips(this, function(clip) { clip.stop() });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment