DisplayObjectUtil
| Kind of class: | public class |
|---|---|
| Package: | org.casalib.util |
| Inherits from: | none |
| Version: | 03/26/10 |
| Author: | Aaron Clinger, Jon Adams |
| Classpath: | org.casalib.util.DisplayObjectUtil |
| File last modified: | Sunday, 28 March 2010, 11:55:55 |
Provides utility functions for DisplayObjects/DisplayObjectContainers.
Summary
Class methods
- removeChildren (parent:DisplayObject, destroyChildren:Boolean = false, recursive:Boolean = false) : void
- Removes and optionally destroys children of a DisplayObjectContainer or the states of a SimpleButton.
- getChildren (parent:DisplayObjectContainer) : Array
- Returns the children of a DisplayObjectContainer as an Array.
- getOffsetPosition (displayObject:DisplayObject) : Point
- Returns the X and Y offset to the top left corner of the DisplayObject.
Class methods
getChildren
public static function getChildren (
parent:DisplayObjectContainer) : Array
Returns the children of a
DisplayObjectContainer as an Array. Parameters:
parent:
The
DisplayObjectContainer from which to get the children from.Returns:
- All the children of the
DisplayObjectContainer.
getOffsetPosition
public static function getOffsetPosition (
displayObject:DisplayObject) : Point
Returns the X and Y offset to the top left corner of the
DisplayObject. The offset can be used to position DisplayObjects whose alignment point is not at 0, 0 and/or is scaled. Parameters:
displayObject:
The
DisplayObject to align.Returns:
- The X and Y offset to the top left corner of the
DisplayObject.
Example:
-
var box:CasaSprite = new CasaSprite(); box.scaleX = -2; box.scaleY = 1.5; box.graphics.beginFill(0xFF00FF); box.graphics.drawRect(-20, 100, 50, 50); box.graphics.endFill(); const offset:Point = DisplayObjectUtil.getOffsetPosition(box); trace(offset) box.x = 10 + offset.x; box.y = 10 + offset.y; this.addChild(box);
removeChildren
public static function removeChildren (
parent:DisplayObject,
destroyChildren:Boolean = false,
recursive:Boolean = false) : void
Removes and optionally destroys children of a
DisplayObjectContainer or the states of a SimpleButton. Parameters:
parent :
The
DisplayObjectContainer from which to remove children or a SimpleButton from which to remove its states.destroyChildren:
If a child implements IDestroyable call its destroy method
true, or don't destroy false; defaults to false.recursive :
Call this method with the same arguments on all of the children's children (all the way down the display list)
true, or leave the children's children false; defaults to false.