addChild method

  1. @override
void addChild (DisplayObject child)

Adds a child DisplayObject to this DisplayObjectContainer.

The child is added to the front (top) of all other children. (To add a child to a specific index position, use addChildAt.)

If you add a child object that already has a different display object container as a parent, the object is removed from the child list of the other display object container.


void addChild(DisplayObject child) {
  if (child == this) {
    throw new ArgumentError(
        "An object cannot be added as a child of itself.");
  } else if (child.parent == this) {
  } else {