As the title suggests, what is 开发者_开发技巧the runtime complexity (eg, big-O) of the Sprite.contains method?
According to the documentation, it's available in any version of Flash Player 9. Have you seen something to indicate otherwise?
I don't have an authoritative answer, but anything other than O(n) would surprise me. It should be a simple walk down the display list, with a simple pointer comparison at each stop.
Should be fast, but it would probably be even faster (depending on the actual display list) to query possible childs parent atribute (with recursion up the parent chain up to to the display list root node) and look if the potential parent sprite is there.
Sprite.getChildByName() is a decidedly worse alternative.
精彩评论