swapChildren method

void swapChildren (DisplayObject child1, DisplayObject child2)

Swaps the z-order (front-to-back order) of the two specified child objects.

All other child objects in the display object container remain in the same index positions.


void swapChildren(DisplayObject child1, DisplayObject child2) {
  int index1 = getChildIndex(child1);
  int index2 = getChildIndex(child2);
  if (index1 == -1 || index2 == -1) {
    throw new ArgumentError(
        "The supplied DisplayObject must be a child of the caller.");
  } else {
    swapChildrenAt(index1, index2);