Class Index | File Index

Classes


Class Container


Extends DisplayObject.
Container are nestable display lists that allow you to work with compound display elements. For example you could group arm, leg, torso and head Bitmaps together into a Person Container, and transform them as a group, while still being able to move the individual parts relative to each other. Children of containers have their transform and alpha properties concatenated with their parent Container. For example, a Shape with x=100 and alpha=0.5, placed in a Container with x=50 and alpha=0.7 will be rendered to the canvas at x=150 and alpha=0.35. Containers have some overhead, so you generally shouldn't create a Container to hold a single child.
Defined in: Container.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Constructs a new Container instance.
Field Summary
Field Attributes Field Name and Description
 
The array of children in the display list.
Fields borrowed from class DisplayObject:
alpha, cacheCanvas, compositeOperation, id, mouseEnabled, name, onClick, onPress, parent, regX, regY, rotation, scaleX, scaleY, shadow, skewX, skewY, snapToPixel, visible, x, y
Method Summary
Method Attributes Method Name and Description
 
addChild(child)
Adds a child to the top of the display list.
 
addChildAt(child, index)
Adds a child to the display list at the specified index, bumping children at equal or greater indexes up one, and setting its parent to this Container.
 
clone(recursive)
Returns a clone of this Container.
 
contains(child)
Returns true if the specified display object either is this container or is a descendent (child, grandchild, etc) of this container.
 
getChildAt(index)
Returns the child at the specified index.
 
Returns the index of the specified child in the display list, or -1 if it is not in the display list.
 
Returns the number of children in the display list.
 
Returns an array of all display objects under the specified coordinates that are in this container's display list.
 
Similar to getObjectsUnderPoint(), but returns only the top-most display object.
 
Removes all children from the display list.
 
removeChild(child)
Removes the specified child from the display list.
 
Removes the child at the specified index from the display list, and sets its parent to null.
 
sortChildren(sortFunction)
Performs an array sort operation on the child list.
Methods borrowed from class DisplayObject:
cache, draw, getConcatenatedMatrix, getStage, globalToLocal, hitTest, isVisible, localToGlobal, localToLocal, toString, uncache, updateCache
Class Detail
Container()
Constructs a new Container instance.
Field Detail
children
The array of children in the display list. You should usually use the child management methods, rather than accessing this directly, but it is included for advanced users.
Method Detail
addChild(child)
Adds a child to the top of the display list. You can also add multiple children, such as "addChild(child1, child2, ...);". Returns the child that was added, or the last child if multiple children were added.
Parameters:
child
The display object to add.

addChildAt(child, index)
Adds a child to the display list at the specified index, bumping children at equal or greater indexes up one, and setting its parent to this Container. You can also add multiple children, such as "addChildAt(child1, child2, ..., index);". The index must be between 0 and numChildren. For example, to add myShape under otherShape in the display list, you could use: container.addChildAt(myShape, container.getChildIndex(otherShape)). This would also bump otherShape's index up by one. Returns the last child that was added, or the last child if multiple children were added.
Parameters:
child
The display object to add.
index
The index to add the child at.

clone(recursive)
Returns a clone of this Container. Some properties that are specific to this instance's current context are reverted to their defaults (for example .parent).
Parameters:
recursive
If true, all of the descendants of this container will be cloned recursively. If false, the properties of the container will be cloned, but the new instance will not have any children.

contains(child)
Returns true if the specified display object either is this container or is a descendent (child, grandchild, etc) of this container.
Parameters:
child

getChildAt(index)
Returns the child at the specified index.
Parameters:
index
The index of the child to return.

getChildIndex(The)
Returns the index of the specified child in the display list, or -1 if it is not in the display list.
Parameters:
The
child to return the index of.

getNumChildren()
Returns the number of children in the display list.

getObjectsUnderPoint(x, y)
Returns an array of all display objects under the specified coordinates that are in this container's display list. This routine ignores any display objects with mouseEnabled set to false. The array will be sorted in order of visual depth, with the top-most display object at index 0. This uses shape based hit detection, and can be an expensive operation to run, so it is best to use it carefully. For example, if testing for objects under the mouse, test on tick (instead of on mousemove), and only if the mouse's position has changed.
Parameters:
x
The x position in the container to test.
y
The y position in the container to test.

getObjectUnderPoint(x, y)
Similar to getObjectsUnderPoint(), but returns only the top-most display object. This runs significantly faster than getObjectsUnderPoint(), but is still an expensive operation. See getObjectsUnderPoint() for more information.
Parameters:
x
The x position in the container to test.
y
The y position in the container to test.

removeAllChildren()
Removes all children from the display list.

removeChild(child)
Removes the specified child from the display list. Note that it is faster to use removeChildAt() if the index is already known. You can also remove multiple children, such as "removeChild(child1, child2, ...);". Returns true if the child (or children) was removed, or false if it was not in the display list.
Parameters:
child
The child to remove.

removeChildAt(The)
Removes the child at the specified index from the display list, and sets its parent to null. You can also remove multiple children, such as "removeChildAt(2, 7, ...);". Returns true if the child (or children) was removed, or false if any index was out of range.
Parameters:
The
index of the child to remove.

sortChildren(sortFunction)
Performs an array sort operation on the child list.
Parameters:
sortFunction

Documentation generated by JsDoc Toolkit 2.3.2 on Sun Feb 13 2011 22:46:00 GMT-0700 (MST)