YUI Flash Component Documentation |
Class DisplayObjectUtil

Package | com.yahoo.astra.utils
Class | public class DisplayObjectUtil

Utility functions for use with DisplayObjects.

Public Methods

| Method | Defined by
--- | --- | ---
|  | align(target:DisplayObject, bounds:Rectangle, horizontalAlign:String = null, verticalAlign:String = null):void [static] Aligns a DisplayObject vertically and horizontally within specific bounds. | DisplayObjectUtil
|  | localToLocal(point:Point, firstDisplayObject:DisplayObject, secondDisplayObject:DisplayObject):Point [static] Converts a point from the local coordinate system of one DisplayObject to the local coordinate system of another DisplayObject. | DisplayObjectUtil
|  | resizeAndMaintainAspectRatio(target:DisplayObject, width:Number, height:Number, aspectRatio:Number):void [static] Resizes a DisplayObject to fit into specified bounds such that the aspect ratio of the target's width and height does not change. | DisplayObjectUtil

Method detail

align | () | method

`public static function align(target:DisplayObject, bounds:Rectangle, horizontalAlign:String = null, verticalAlign:String = null):void`

Aligns a DisplayObject vertically and horizontally within specific bounds.

Parameters

| `target:DisplayObject` — The DisplayObject to align.
| `bounds:Rectangle` — The rectangle in which to align the target DisplayObject.
| `horizontalAlign:String` (default = `null`)`` — The alignment position along the horizontal axis. If `null`, the target's horizontal position will not change.
| `verticalAlign:String` (default = `null`)`` — The alignment position along the vertical axis. If `null`, the target's vertical position will not change.

localToLocal | () | method |

`public static function localToLocal(point:Point, firstDisplayObject:DisplayObject, secondDisplayObject:DisplayObject):Point`

Converts a point from the local coordinate system of one DisplayObject to the local coordinate system of another DisplayObject.

Parameters

| `point:Point` — the point to convert
| `firstDisplayObject:DisplayObject` — the original coordinate system
| `secondDisplayObject:DisplayObject` — the new coordinate system

Returns

| `Point`

resizeAndMaintainAspectRatio | () | method |

`public static function resizeAndMaintainAspectRatio(target:DisplayObject, width:Number, height:Number, aspectRatio:Number):void`

Resizes a DisplayObject to fit into specified bounds such that the aspect ratio of the target's width and height does not change.

Parameters

| `target:DisplayObject` — The DisplayObject to resize.
| `width:Number` — The desired width for the target.
| `height:Number` — The desired height for the target.
| `aspectRatio:Number` — The desired aspect ratio. If NaN, the aspect ratio is calculated from the target's current width and height.