Packagecom.threerings.display
Classpublic class DisplayUtil



Public Methods
 MethodDefined by
  
addChildAbove(container:DisplayObjectContainer, newChild:DisplayObject, above:DisplayObject):void
[static] Adds newChild to container, directly above another child of the container.
DisplayUtil
  
addChildBelow(container:DisplayObjectContainer, newChild:DisplayObject, below:DisplayObject):void
[static] Adds newChild to container, directly below another child of the container.
DisplayUtil
  
applyToHierarchy(disp:DisplayObject, callbackFunction:Function):void
[static] Call the specified function for the display object and all descendants.
DisplayUtil
  
centerRectInRect(rect:Rectangle, bounds:Rectangle):Point
[static] Center the specified rectangle within the specified bounds.
DisplayUtil
  
createPointSorter(origin:Point):Function
[static] Create a sort Function that can be used to compare Points in an Array according to their distance from the specified Point.
DisplayUtil
  
dumpHierarchy(top:DisplayObject):String
[static] Dump the display hierarchy to a String, each component on a newline, children indented two spaces: "instance0" flash.display.Sprite "instance1" flash.display.Sprite "entry_box" flash.text.TextField Note: This method will not dump rawChildren of flex componenets.
DisplayUtil
  
findInHierarchy(top:DisplayObject, name:String, findShallow:Boolean = true, maxDepth:int):DisplayObject
[static] Find a component with the specified name in the specified display hierarchy.
DisplayUtil
  
fitRectInRect(rect:Rectangle, bounds:Rectangle):Point
[static] Returns the most reasonable position for the specified rectangle to be placed at so as to maximize its containment by the specified bounding rectangle while still placing it as near its original coordinates as possible.
DisplayUtil
  
positionBounds(disp:DisplayObject, x:Number, y:Number):void
[static] Sets the top-left pixel of a DisplayObject to the given location, taking the object's bounds into account.
DisplayUtil
  
positionBoundsRelative(disp:DisplayObject, relativeTo:DisplayObject, x:Number, y:Number):void
[static] Sets the top-left pixel of a DisplayObject to the given location, relative to another DisplayObject's coordinate space.
DisplayUtil
  
positionRect(r:Rectangle, bounds:Rectangle, avoid:Array):Boolean
[static] Position the specified rectangle within the bounds, avoiding any of the Rectangles in the avoid array, which may be destructively modified.
DisplayUtil
  
sortDisplayChildren(container:DisplayObjectContainer, comp:Function = null):void
[static] Sorts a container's children, using ArrayUtil.stableSort.
DisplayUtil
  
transformPoint(p:Point, fromDisp:DisplayObject, toDisp:DisplayObject):Point
[static] Transforms a point from one DisplayObject's coordinate space to another's.
DisplayUtil
Method detail
addChildAbove()method
public static function addChildAbove(container:DisplayObjectContainer, newChild:DisplayObject, above:DisplayObject):void

Adds newChild to container, directly above another child of the container.

Parameters
container:DisplayObjectContainer
 
newChild:DisplayObject
 
above:DisplayObject
addChildBelow()method 
public static function addChildBelow(container:DisplayObjectContainer, newChild:DisplayObject, below:DisplayObject):void

Adds newChild to container, directly below another child of the container.

Parameters
container:DisplayObjectContainer
 
newChild:DisplayObject
 
below:DisplayObject
applyToHierarchy()method 
public static function applyToHierarchy(disp:DisplayObject, callbackFunction:Function):void

Call the specified function for the display object and all descendants. This is nearly exactly like mx.utils.DisplayUtil.walkDisplayObjects, except this method copes with security errors when examining a child.

Parameters
disp:DisplayObject
 
callbackFunction:Function
centerRectInRect()method 
public static function centerRectInRect(rect:Rectangle, bounds:Rectangle):Point

Center the specified rectangle within the specified bounds. If the bounds are too small then the rectangle will be pinned to the upper-left.

Parameters
rect:Rectangle
 
bounds:Rectangle

Returns
Point
createPointSorter()method 
public static function createPointSorter(origin:Point):Function

Create a sort Function that can be used to compare Points in an Array according to their distance from the specified Point. Note: The function will always sort according to distance from the passed-in point, even if that point's coordinates change after the function is created.

Parameters
origin:Point

Returns
Function
dumpHierarchy()method 
public static function dumpHierarchy(top:DisplayObject):String

Dump the display hierarchy to a String, each component on a newline, children indented two spaces: "instance0" flash.display.Sprite "instance1" flash.display.Sprite "entry_box" flash.text.TextField Note: This method will not dump rawChildren of flex componenets.

Parameters
top:DisplayObject

Returns
String
findInHierarchy()method 
public static function findInHierarchy(top:DisplayObject, name:String, findShallow:Boolean = true, maxDepth:int):DisplayObject

Find a component with the specified name in the specified display hierarchy. Whether finding deeply or shallowly, if two components have the target name and are at the same depth, the first one found will be returned. Note: This method will not find rawChildren of flex componenets.

Parameters
top:DisplayObject
 
name:String
 
findShallow:Boolean (default = true)
 
maxDepth:int

Returns
DisplayObject
fitRectInRect()method 
public static function fitRectInRect(rect:Rectangle, bounds:Rectangle):Point

Returns the most reasonable position for the specified rectangle to be placed at so as to maximize its containment by the specified bounding rectangle while still placing it as near its original coordinates as possible.

Parameters
rect:Rectangle — the rectangle to be positioned.
 
bounds:Rectangle — the containing rectangle.

Returns
Point
positionBounds()method 
public static function positionBounds(disp:DisplayObject, x:Number, y:Number):void

Sets the top-left pixel of a DisplayObject to the given location, taking the object's bounds into account.

Parameters
disp:DisplayObject
 
x:Number
 
y:Number
positionBoundsRelative()method 
public static function positionBoundsRelative(disp:DisplayObject, relativeTo:DisplayObject, x:Number, y:Number):void

Sets the top-left pixel of a DisplayObject to the given location, relative to another DisplayObject's coordinate space.

Parameters
disp:DisplayObject
 
relativeTo:DisplayObject
 
x:Number
 
y:Number
positionRect()method 
public static function positionRect(r:Rectangle, bounds:Rectangle, avoid:Array):Boolean

Position the specified rectangle within the bounds, avoiding any of the Rectangles in the avoid array, which may be destructively modified.

Parameters
r:Rectangle
 
bounds:Rectangle
 
avoid:Array

Returns
Boolean — true if the rectangle was successfully placed, given the constraints, or false if the positioning failed (the rectangle will be left at its original location.
sortDisplayChildren()method 
public static function sortDisplayChildren(container:DisplayObjectContainer, comp:Function = null):void

Sorts a container's children, using ArrayUtil.stableSort. comp is a function that takes two DisplayObjects, and returns int -1 if the first object should appear before the second in the container, 1 if it should appear after, and 0 if the order does not matter. If omitted, Comparators.COMPARABLE will be used- all the children should implement Comparable.

Parameters
container:DisplayObjectContainer
 
comp:Function (default = null)
transformPoint()method 
public static function transformPoint(p:Point, fromDisp:DisplayObject, toDisp:DisplayObject):Point

Transforms a point from one DisplayObject's coordinate space to another's.

Parameters
p:Point
 
fromDisp:DisplayObject
 
toDisp:DisplayObject

Returns
Point