ActionScript 3Working With Display Objects


Syntax

  1. addChild(child) - adds a new item to this object's child tree as the topmost element.
  2. addChildAt(child, index) - adds a new item to this object's child tree at a specified position. The bottom-most item has index of 0.
  3. getChildAt(index) - returns a child with given index.
  4. getChildIndex(child) returns the index of a direct child of this object. Otherwise an exception is thrown.
  5. removeChild(child) - removes the specified direct child from this object's child tree. Throws exception if the supplied child's parent is not equal to this.
  6. removeChildAt(index) - removes a child selected by index instead of reference. Throws exception if the child tree is not this wide.
  7. removeChildren(beginIndex:int = 0, endIndex:int = 0x7fffffff)) - added in Flash Player 11, removes a subset of children by index range, or all children if called with no parameters.
  8. setChildIndex(child,index) - changes the child's index to the new value, shifting all children in between to occupy the released spot.
  9. swapChildren(child1,child2) - swaps the two children's positions in display list, not affecting positions of other children.
  10. swapChildrenAt(index1,index2) - swaps children located by their indexes.

Remarks

The display list is actually a tree, and is visualized with depth first algorithm. Any object listed earlier will be displayed earlier, and might be obscured by objects listed later. All techniques that can be used against a tree can be applied to working with display list.