Adobe® Flex® 4 Language Reference
Hide Packages and Classes List |  Packages  |  Classes  |  Index  |  Appendixes
mx.core 
IChildList 
Packagemx.core
Interfacepublic interface IChildList
Implementors Container, SystemManager, UIComponent

Language Version: ActionScript 3.0
Product Version: Flex 3
Runtime Versions: Flash Player 9, AIR 1.1

The IChildList interface defines the properties and methods for accessing and manipulating child lists, which are subsets of a DisplayObjectContainer's children.

As an example, consider the Container class. It overrides DisplayObjectContainer APIs such as the numChildren and getChildAt() methods to access only "content" children, which are the controls and other containers that you put inside it. But a Container can also have additional children created automatically by the framework, such as a background or border skin and scrollbars. So Container exposes a property called rawChildren of type IChildList, which lets you access all its children, not just the content children.

As another example, the SystemManager class is a DisplayObjectContainer whose children are partitioned into various layers: normal children like the Application are on the bottom, popups above them, tooltips above them, and cursors on the top. The SystemManager class has properties named popUpChildren, toolTipChildren, and cursorChildren which let you access these layers, and the type of each of these properties is IChildList. Therefore, you can count the number of popups using the systemManager.popUpChildren.numChildren property, insert another DisplayObject into the tooltip layer using the systemManager.toolTipChildren.addChild() method, and so on.

See also



Public Properties
 PropertyDefined By
  numChildren : int
[read-only] The number of children in this child list.
IChildList
Public Methods
 MethodDefined By
  
Adds a child DisplayObject after the end of this child list.
IChildList
  
Adds a child DisplayObject to this child list at the index specified.
IChildList
  
Determines if a DisplayObject is in this child list, or is a descendant of an child in this child list.
IChildList
  
Gets the child DisplayObject at the specified index in this child list.
IChildList
  
Gets the child DisplayObject with the specified name in this child list.
IChildList
  
Gets the index of a specific child in this child list.
IChildList
  
Returns an array of DisplayObjects that lie under the specified point and are in this child list.
IChildList
  
Removes the specified child DisplayObject from this child list.
IChildList
  
Removes the child DisplayObject at the specified index from this child list.
IChildList
  
Changes the index of a particular child in this child list.
IChildList
Property Detail

numChildren

property
numChildren:int  [read-only]

Language Version: ActionScript 3.0
Product Version: Flex 3
Runtime Versions: Flash Player 9, AIR 1.1

The number of children in this child list.



Implementation
    public function get numChildren():int
Method Detail

addChild

()method
public function addChild(child:DisplayObject):DisplayObject

Language Version: ActionScript 3.0
Product Version: Flex 3
Runtime Versions: Flash Player 9, AIR 1.1

Adds a child DisplayObject after the end of this child list.

Calling childList.addChild(child) is the same as calling childList.addChild(child, childList.numChildren) After it has been added, its index of the new child will be (child.numChildren - 1)

Parameters

child:DisplayObject — The DisplayObject to add as a child.

Returns
DisplayObject — The child that was added; this is the same as the argument passed in.

addChildAt

()method 
public function addChildAt(child:DisplayObject, index:int):DisplayObject

Language Version: ActionScript 3.0
Product Version: Flex 3
Runtime Versions: Flash Player 9, AIR 1.1

Adds a child DisplayObject to this child list at the index specified. An index of 0 represents the beginning of the DisplayList, and an index of numChildren represents the end.

Adding a child anywhere except at the end of a child list will increment the indexes of children that were previously at that index or at higher indices.

Parameters

child:DisplayObject — The DisplayObject to add as a child.
 
index:int — The index to add the child at.

Returns
DisplayObject — The child that was added; this is the same as the child argument passed in.

contains

()method 
public function contains(child:DisplayObject):Boolean

Language Version: ActionScript 3.0
Product Version: Flex 3
Runtime Versions: Flash Player 9, AIR 1.1

Determines if a DisplayObject is in this child list, or is a descendant of an child in this child list.

Parameters

child:DisplayObject — The DisplayObject to test.

Returns
Booleantrue if the DisplayObject is in this child list or is a descendant of an child in this child list; false otherwise.

getChildAt

()method 
public function getChildAt(index:int):DisplayObject

Language Version: ActionScript 3.0
Product Version: Flex 3
Runtime Versions: Flash Player 9, AIR 1.1

Gets the child DisplayObject at the specified index in this child list.

Parameters

index:int — An integer from 0 to (numChildren - 1) that specifies the index of a child in this child list.

Returns
DisplayObject — The child at the specified index.

getChildByName

()method 
public function getChildByName(name:String):DisplayObject

Language Version: ActionScript 3.0
Product Version: Flex 3
Runtime Versions: Flash Player 9, AIR 1.1

Gets the child DisplayObject with the specified name in this child list.

Parameters

name:String — The name of the child to return.

Returns
DisplayObject — The child with the specified name.

getChildIndex

()method 
public function getChildIndex(child:DisplayObject):int

Language Version: ActionScript 3.0
Product Version: Flex 3
Runtime Versions: Flash Player 9, AIR 1.1

Gets the index of a specific child in this child list.

The first child in the child list has an index of 0, the second child has an index of 1, and the last child has an index of (numChildren - 1).

If getChildIndex(myChild) returns 5, then myView.getChildAt(5) returns myChild.

If you add a child by calling the addChild() method, the new child's index is equal to the largest index among the existing children plus one.

You can insert a child at a specified index by using the addChildAt() method In that case the children previously at that index and higher indices have their index increased by 1 so that all children are indexed from 0 to (numChildren - 1).

If you remove a child by calling the removeChild() or removeChildAt() method, then the children at higher indices have their index decreased by 1 so that all children are indexed from 0 to (numChildren - 1).

If you change a child's index by calling the setChildIndex() method, then the children between the old index and the new index, inclusive, have their indexes adjusted so that all children are indexed from 0 to (numChildren - 1).

Parameters

child:DisplayObject — The child whose index to get.

Returns
int — The index of the child, which is an integer between 0 and (numChildren - 1).

getObjectsUnderPoint

()method 
public function getObjectsUnderPoint(point:Point):Array

Language Version: ActionScript 3.0
Product Version: Flex 3
Runtime Versions: Flash Player 9, AIR 1.1

Returns an array of DisplayObjects that lie under the specified point and are in this child list.

Parameters

point:Point — The point under which to look.

Returns
Array — An array of object that lie under the specified point that are children of this Container.

removeChild

()method 
public function removeChild(child:DisplayObject):DisplayObject

Language Version: ActionScript 3.0
Product Version: Flex 3
Runtime Versions: Flash Player 9, AIR 1.1

Removes the specified child DisplayObject from this child list.

Removing a child anywhere except from the end of a child list will decrement the indexes of children that were at higher indices.

The removed child will have its parent set to null and will be garbage collected if no other references to it exist.

Parameters

child:DisplayObject — The DisplayObject to remove.

Returns
DisplayObject — The child that was removed; this is the same as the argument passed in.

removeChildAt

()method 
public function removeChildAt(index:int):DisplayObject

Language Version: ActionScript 3.0
Product Version: Flex 3
Runtime Versions: Flash Player 9, AIR 1.1

Removes the child DisplayObject at the specified index from this child list.

Removing a child anywhere except from the end of a child list will decrement the indexes of children that were at higher indices.

The removed child will have its parent set to null and will be garbage collected if no other references to it exist.

Parameters

index:int — The child index of the DisplayObject to remove.

Returns
DisplayObject — The child that was removed.

setChildIndex

()method 
public function setChildIndex(child:DisplayObject, newIndex:int):void

Language Version: ActionScript 3.0
Product Version: Flex 3
Runtime Versions: Flash Player 9, AIR 1.1

Changes the index of a particular child in this child list. See the getChildIndex() method for a description of the child's index.

Parameters

child:DisplayObject — The child whose index to set.
 
newIndex:int — The new index for the specified child. This must be an integer between zero and (numChildren - 1).