Packageflare.util
Classpublic class Displays

Utility methods for working with display objects. The methods include support for panning, rotating, and zooming objects, generating thumbnail images, traversing children lists, and adding stage listeners.



Public Methods
 MethodDefined by
  
Constructor, throws an error if called, as this is an abstract class.
Displays
  
addStageListener(d:DisplayObject, eventType:String, listener:Function, useCapture:Boolean = false, priority:Number = 0, useWeakReference:Boolean = false):Function
[static] Adds a listener to the stage via a given display object.
Displays
  
panBy(obj:DisplayObject, dx:Number, dy:Number, vp:IValueProxy = null):void
[static] Pan the "camera" by the specified amount.
Displays
  
panMatrixBy(mat:Matrix, dx:Number, dy:Number):Matrix
[static] Performs a pan (translation) on an input matrix.
Displays
  
rotateMatrixBy(mat:Matrix, angle:Number, p:Point):Matrix
[static] Performs a rotation around a specific point on an input matrix.
Displays
  
setChildrenProperties(d:DisplayObjectContainer, vals:Object, p:IValueProxy = null):void
[static] Sets property values on all children items.
Displays
  
sortChildren(d:DisplayObjectContainer, cmp:Function):void
[static] Sorts the children of the given DisplayObjectContainer using a comparator function.
Displays
  
thumbnail(src:DisplayObject, width:Number = -1, height:Number = -1, bd:BitmapData = null):BitmapData
[static] Creates a thumbnail image of the input object using the (optional) given size.
Displays
  
visitChildren(con:DisplayObjectContainer, visitor:Function, filter:Boolean = null, reverse:* = false):Boolean
[static] Iterates over the children of the input display object container, invoking a visitor function on each.
Displays
  
zoomBy(obj:DisplayObject, scale:Number, xp:Number, yp:Number, vp:IValueProxy = null):void
[static] Zoom the "camera" by the specified scale factor.
Displays
  
zoomMatrixBy(mat:Matrix, scale:Number, p:Point):Matrix
[static] Performs a zoom about a specific point on an input matrix.
Displays
Constructor detail
Displays()constructor
public function Displays()

Constructor, throws an error if called, as this is an abstract class.

Method detail
addStageListener()method
public static function addStageListener(d:DisplayObject, eventType:String, listener:Function, useCapture:Boolean = false, priority:Number = 0, useWeakReference:Boolean = false):Function

Adds a listener to the stage via a given display object. If the display object has already been added to the stage, the listener will be added to the stage immediately. Otherwise, the listener will be added whenever the display object is added to the stage. This method allows you to add listeners for stage events without having to explicitly manage the case where the defining elements have not yet been added to the stage.

Parameters
d:DisplayObject — the display object through which to access the stage
 
eventType:String — the event type
 
listener:Function — the event listener
 
useCapture:Boolean (default = false) — the event useCapture flag
 
priority:Number (default = 0) — the event listener priority
 
useWeakReference:Boolean (default = false) — the event useWeakReference flag

Returns
Function — the function that will add the listener to the stage upon an added to stage event, or null if the listener was directly added to the stage

See also

flash.events.Event
panBy()method 
public static function panBy(obj:DisplayObject, dx:Number, dy:Number, vp:IValueProxy = null):void

Pan the "camera" by the specified amount.

Parameters
obj:DisplayObject — the display object to treat as the camera
 
dx:Number — the change in x position, in the parent's coordinate space
 
dy:Number — the change in y position, in the parent's coordinate space
 
vp:IValueProxy (default = null) — an optional value proxy (such as a Transitioner) for storing the new transform matrix
panMatrixBy()method 
public static function panMatrixBy(mat:Matrix, dx:Number, dy:Number):Matrix

Performs a pan (translation) on an input matrix. The result is a transformation matrix including the translation.

Parameters
mat:Matrix — an input transformation matrix
 
dx:Number — the change in x position
 
dy:Number — the change in y position

Returns
Matrix — the resulting, panned transformation matrix
rotateMatrixBy()method 
public static function rotateMatrixBy(mat:Matrix, angle:Number, p:Point):Matrix

Performs a rotation around a specific point on an input matrix. The result is a transformation matrix including the rotation.

Parameters
mat:Matrix — an input transformation matrix
 
angle:Number — the rotation angle, in degrees
 
p:Point — the point about which to zoom in or out

Returns
Matrix — the resulting, rotated transformation matrix
setChildrenProperties()method 
public static function setChildrenProperties(d:DisplayObjectContainer, vals:Object, p:IValueProxy = null):void

Sets property values on all children items. The values within the vals argument can take a number of forms:

Parameters
d:DisplayObjectContainer — the container whose children's properties should be set.
 
vals:Object — an object containing the properties and values to set.
 
p:IValueProxy (default = null) — an optional IValueProxy for collecting value updates.
sortChildren()method 
public static function sortChildren(d:DisplayObjectContainer, cmp:Function):void

Sorts the children of the given DisplayObjectContainer using a comparator function.

Parameters
d:DisplayObjectContainer — a display object container to sort. The sort may change the rendering order in which the contained display objects are drawn.
 
cmp:Function — a comparator Function.
thumbnail()method 
public static function thumbnail(src:DisplayObject, width:Number = -1, height:Number = -1, bd:BitmapData = null):BitmapData

Creates a thumbnail image of the input object using the (optional) given size. If no width, height, or bitmap data parameters are provided then the natural size of the display object will be used. If no width or height values are provided (i.e., they are less than or equal to zero) but a bitmap data is provided, than the dimensions of the bitmap data will be used. If all parameters are provided but the width and height exceed the size of the bitmap data, then the object will be drawn to match the provided width and height, but the thumbnail will be clipped to the size of the bitmap data. If only one of the width or height values are provided, than the other will automatically be selected to preserve the original aspect ratio of the object.

Parameters
src:DisplayObject — the DisplayObject to create a thumbnail image of
 
width:Number (default = -1) — the desired width of the object in the thumbnail. If this value is less than or equal to zero it is ignored.
 
height:Number (default = -1) — the desired height of the object in the thumbnail If this value is less than or equal to zero it is ignored.
 
bd:BitmapData (default = null) — a BitmapData instance into which to draw the thumbnail. If no value is provided, a new BitmapData instance of the needed width and height will automatically be created.

Returns
BitmapData — the thumbnail image as a BitmapData instance
visitChildren()method 
public static function visitChildren(con:DisplayObjectContainer, visitor:Function, filter:Boolean = null, reverse:* = false):Boolean

Iterates over the children of the input display object container, invoking a visitor function on each. If the visitor function returns a Boolean true value, the iteration will stop with an early exit.

Parameters
con:DisplayObjectContainer — the container to visit
 
visitor:Function — the visitor function to invoke on the children
 
filter:Boolean (default = null) — an optional filter indicating which items should be visited
 
reverse:* (default = false) — optional flag indicating if the list should be visited in reverse order

Returns
Boolean — true if the visitation was interrupted with an early exit
zoomBy()method 
public static function zoomBy(obj:DisplayObject, scale:Number, xp:Number, yp:Number, vp:IValueProxy = null):void

Zoom the "camera" by the specified scale factor.

Parameters
obj:DisplayObject — the display object to treat as the camera
 
scale:Number — a scale factor specifying the amount to zoom. A value of 2 will zoom in such that objects are twice as large. A value of 0.5 will zoom out such that objects are half the size.
 
xp:Number — the x-coordinate around which to zoom, in stage coordinates. If this value is NaN, 0 will be used.
 
yp:Number — the y-coordinate around which to zoom, in stage coordinates. If this value is NaN, 0 will be used.
 
vp:IValueProxy (default = null) — an optional value proxy (such as a Transitioner) for storing the new transform matrix
zoomMatrixBy()method 
public static function zoomMatrixBy(mat:Matrix, scale:Number, p:Point):Matrix

Performs a zoom about a specific point on an input matrix. The result is a transformation matrix including the zoom.

Parameters
mat:Matrix — an input transformation matrix
 
scale:Number — a scale factor specifying the amount to zoom. A value of 2 will zoom in such that objects are twice as large. A value of 0.5 will zoom out such that objects are half the size.
 
p:Point — the point about which to zoom in or out

Returns
Matrix — the resulting, zoomed transformation matrix