Regarding the way findNode() searches by ID, TFM says:
"ifSGNodeDict" wrote:
findNode(name as String) as Object
Returns the node that is a descendant of the nearest component ancestor of the subject node (possibly the subject node itself) and whose id field is set to name. The search for the descendant node is a breadth-first search that includes child nodes in nodes that are declared as custom components defined in other XML component files. These together allow finding siblings and cousins of a node within the context of a component. If a node with the specified name is not found, an invalid object is returned.
The intent is for the ID to be unique in this context, but the first node matched in a breadth-first, top-down, first child to last child, traversal will be returned.
... and that seems mostly right - except for the the "breadth-first" part. I did a quick test and the ID was found in a
depth-first manner (i.e. recursive descent). I was intrigued initially by the claim since doing BFS is harder and unnecessary in light of the footnote. Here is example, scene having these children:
<children>
<Rectangle>
<Label id = "ID1"/>
</Rectangle>
<Timer id = "ID1"/>
</children>
Given this, per TFM
scene.findNode("ID1") should return the
Timer - but it doesn't, instead it returns the
Label. I.e. it is the first found when doing depth-first walk. Children are tested first before the remaining siblings. Thus,
the doco page needs fixing.[spoiler=DFS vs BFS refresher:30uyt78s]
Depth-First Search Breadth-First Search [/spoiler:30uyt78s]