getChildByName method

  1. @override
DisplayObject getChildByName (String name)
override

Returns the child DisplayObject that exists with the specified name.

If more that one child DisplayObject has the specified name, the method returns the first object in the child list.

The getChildAt method is faster than the getChildByName method. The getChildAt method accesses a child from a cached array, whereas the getChildByName method has to traverse a list to access a child.

Implementation

@override
DisplayObject getChildByName(String name) {
  for (int i = 0; i < _children.length; i++) {
    DisplayObject child = _children[i];
    if (child.name == name) return child;
  }
  return null;
}