Packagegraphics.display
Classpublic class DisplayObjects
InheritanceDisplayObjects Inheritance Object

The DisplayObject tool class.

Example :

     import graphics.Align ;
     import graphics.display.DisplayObjects ;
     
     import flash.display.Shape ;
     import flash.geom.Rectangle ;
     
     stage.scaleMode = "noScale" ;
     stage.align     = "tl" ;
     
     var background:Shape = new Shape() ;
     
     background.graphics.beginFill( 0x333333 ) ;
     background.graphics.drawRect(0,0,100,100) ;
     
     background.x = 100 ;
     background.y = 100 ;
     
     addChild( background ) ;
     
     var shape:Shape = new Shape() ;
     
     shape.graphics.beginFill( 0x666666 ) ;
     shape.graphics.drawRect(0,0,100,100) ;
     
     shape.x = 100 ;
     shape.y = 100 ;
     
     addChild( shape ) ;
          var area:Rectangle = new Rectangle(100,100,100,100) ;
      
     DisplayObjects.resize(shape, 50, 50) ;
     DisplayObjects.align(shape, area, Align.CENTER) ;
     
     trace( DisplayObjects.originalHeight(shape) ) ; // 100
     trace( DisplayObjects.originalWidth(shape) ) ; // 100
     



Public Methods
 MethodDefined By
  
align(target:DisplayObject, bounds:Rectangle, align:Number = 10, offset:Point = null, propWidth:String = width, propHeight:String = height):void
[static] Aligns a DisplayObject within specific bounds.
DisplayObjects
  
localToLocal(point:Point, from:DisplayObject, to:DisplayObject):Point
[static] Converts a point from the local coordinate system of one DisplayObject to the local coordinate system of another DisplayObject.
DisplayObjects
  
originalHeight(target:DisplayObject):Number
[static] Returns the original height in pixels of the specified DisplayObject.
DisplayObjects
  
originalWidth(target:DisplayObject):Number
[static] Returns the original width in pixels of the specified DisplayObject.
DisplayObjects
  
resize(target:DisplayObject, width:Number, height:Number, aspectRatio:* = null):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.
DisplayObjects
  
rotate(target:DisplayObject, angle:Number, anchor:* = null):void
[static] Rotates the specified DisplayObject with a specific custom center of rotation.
DisplayObjects
Method Detail
align()method
public static function align(target:DisplayObject, bounds:Rectangle, align:Number = 10, offset:Point = null, propWidth:String = width, propHeight:String = height):void

Aligns a DisplayObject within specific bounds.

Parameters

target:DisplayObject — The DisplayObject to align.
 
bounds:Rectangle — The rectangle in which to align the target DisplayObject.
 
align:Number (default = 10) — The Align value to defines the position of the display in the specified bounds (default Align.TOP_LEFT).

You can use the Align values :

bottom : Align.BOTTOM, Align.BOTTOM_LEFT, Align.BOTTOM_RIGHT

center : Align.CENTER, Align.CENTER_LEFT, Align.CENTER_RIGHT

top : Align.TOP , Align.TOP_LEFT , Align.TOP_RIGHT

 
offset:Point (default = null) — The offset point to translate the target after the alignment process.
 
propWidth:String (default = width) — The name of the width property of the target reference (default "width").
 
propHeight:String (default = height) — The name of the height property of the target reference (default "height").

localToLocal()method 
public static function localToLocal(point:Point, from:DisplayObject, to: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
 
from:DisplayObject — The original coordinate display system.
 
to:DisplayObject — The new coordinate display system.

Returns
Point
originalHeight()method 
public static function originalHeight(target:DisplayObject):Number

Returns the original height in pixels of the specified DisplayObject.

Parameters

target:DisplayObject — The passed-in display to check.

Returns
Number — the original height in pixels of the specified DisplayObject.
originalWidth()method 
public static function originalWidth(target:DisplayObject):Number

Returns the original width in pixels of the specified DisplayObject.

Parameters

target:DisplayObject — The passed-in display to check.

Returns
Number — the original width in pixels of the specified DisplayObject.
resize()method 
public static function resize(target:DisplayObject, width:Number, height:Number, aspectRatio:* = null):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:* (default = null) — The optional desired aspect ratio (a Number or a AspectRatio object) or true to use the current aspect ratio of the display.

rotate()method 
public static function rotate(target:DisplayObject, angle:Number, anchor:* = null):void

Rotates the specified DisplayObject with a specific custom center of rotation.

Parameters

target:DisplayObject — The DisplayObject to rotate.
 
angle:Number — The angle in degrees of the rotation.
 
anchor:* (default = null) — The optional Point to defines the anchor of the rotation (default [0,0)).