Packagegs.managers
Classpublic final class LayoutManager

The LayoutManager class provides shortcuts for many alignment and layering operations.

DisplayObjects must have their registration point at 0,0 in order for the align / stage align methods to function correctly. Otherwise you'll see shifts in what is expected.

The LayoutManager can also align objects to inner and outer edges of target display objects.


Example
Using a layout manager from a CoreClip.
 
  public class MyClip extends CoreClip
  {
      public function MyClip()
      {
          super(); //critical
          
          var mc1:MovieClip = new MovieClip();
          //draw vector box in mc1 here...
         
          var mc2:MovieClip = new MovieClip();
          //draw vector box in mc2 here...
          
          var mc3:MovieClip = new MovieClip();
          //draw vector box in mc3 here...
          
          lm.addChildren(mc1,mc2,mc3); //shortcut to add multiple children.
          
          lm.bringInFront(mc1,mc2); //moves mc1 in front of mc2.
          lm.sendToBack(mc1); //sends mc1 all the way to the back.
          lm.bringForward(mc2); //brings mc2 forward (in front of mc3).
      }
  }
  

Examples are in the guttershark repository.



Public Properties
 PropertyDefined by
  ALIGN_INNER : String = "inner"
[static] An alignment mode that causes the inner edges to be aligned.
LayoutManager
  ALIGN_OUTER : String = "outer"
[static] An alignment mode that causes the outer edges to be aligned.
LayoutManager
  ignoreStageAlign : Boolean = true
[static] Ignore the stage align property and correctly translate stage alignment operations to the actual stage viewport - meaning if the stage.align property is anything other than undefined or TOP_LEFT, correctly translate the positioning offsets that occur when setting x and y.
LayoutManager
  StageRef : Stage
[static] a reference to the stage
LayoutManager
  wholePixels : Boolean = true
[static] Whether or not to use whole pixels on for x and y coordinates.
LayoutManager
Protected Properties
 PropertyDefined by
  container : DisplayObjectContainer
The container in which layering operations will occur.
LayoutManager
Public Methods
 MethodDefined by
  
LayoutManager(target:DisplayObjectContainer)
Constructor for LayoutManager instances.
LayoutManager
  
addChildren(... children):void
Add all children specified to the display list.
LayoutManager
  
addChildrenTo(target:DisplayObjectContainer, ... children):void
Add all children specified onto the display list of the target container.
LayoutManager
  
alignBottom(alignMode:String, relativeTo:DisplayObject, ... targets):void
Align a display object to the bottom edge of another display object.
LayoutManager
  
alignBottomCenter(alignMode:String, relativeTo:DisplayObject, ... targets):void
Align a display object to the bottom center of another display object.
LayoutManager
  
alignBottomLeft(alignModeX:String, alignModeY:String, relativeTo:DisplayObject, ... targets):void
Align a display object to the bottom left corner of another display object.
LayoutManager
  
alignBottomRight(alignModeX:String, alignModeY:String, relativeTo:DisplayObject, ... targets):void
Align a display object to the bottom right corner of another display object.
LayoutManager
  
alignCenter(relativeTo:DisplayObject, ... targets):void
Align a display object to the dead center of another display object.
LayoutManager
  
alignColumn(options:Object, ... objs):void
Align any objects in a vertical stack (column) on y.
LayoutManager
  
alignLeft(alignMode:String, relativeTo:DisplayObject, ... targets):void
Align the target display object to the left edge of another display object.
LayoutManager
  
alignMiddleLeft(alignMode:String, relativeTo:DisplayObject, ... targets):void
Align a display object to the left middle of another display object.
LayoutManager
  
alignMiddleRight(alignMode:String, relativeTo:DisplayObject, ... targets):void
Align a display object to the right middle of another display object.
LayoutManager
  
alignRight(alignMode:String, relativeTo:DisplayObject, ... targets):void
Align the target display object to the right edge of another display object.
LayoutManager
  
alignTop(alignMode:String, relativeTo:DisplayObject, ... targets):void
Align a display object to the top edge of another display object.
LayoutManager
  
alignTopCenter(alignMode:String, relativeTo:DisplayObject, ... targets):void
Align a display object to the top center of another display object.
LayoutManager
  
alignTopLeft(alignModeX:String, alignModeY:String, relativeTo:DisplayObject, ... targets):void
Align a display object to the top left corner of another display object.
LayoutManager
  
alignTopRight(alignModeX:String, alignModeY:String, relativeTo:DisplayObject, ... targets):void
Align a display object to the top right corner of another display object.
LayoutManager
  
alignXCenter(relativeTo:DisplayObject, ... targets):void
Align the target display object centered on the x coordinate relatively to another display object.
LayoutManager
  
alignYCenter(relativeTo:DisplayObject, ... targets):void
Align the target display object centered on the y coordinate relatively to another display object.
LayoutManager
  
bringForward(target:DisplayObject):void
Bring a display object forward 1 layer.
LayoutManager
  
bringInFront(target:DisplayObject, relativeTo:DisplayObject):void
Bring a target display object in front of another display object.
LayoutManager
  
bringToFront(target:DisplayObject):void
Bring the target display object to the top most layer.
LayoutManager
  
dispose():void
Dispose of this layout manager.
LayoutManager
  
getAllChildren(target:Sprite):Array
Returns an array of all the children on the targets display list.
LayoutManager
  
Returns the stage dead center point.
LayoutManager
  
Remove all children from the display list.
LayoutManager
  
removeAllChildrenFrom(target:DisplayObjectContainer):void
Remove all children from the display list of the specified target object.
LayoutManager
  
removeChildren(... children):void
Remove all children specified from the display list.
LayoutManager
  
removeChildrenFrom(target:DisplayObjectContainer, ... children):void
Remove specified children from the target DisplayObjectContainer's display list.
LayoutManager
  
sendBackward(target:DisplayObject):void
Send the target display object backward 1 layer.
LayoutManager
  
sendBehind(target:DisplayObject, relativeTo:DisplayObject):void
Send a target display object behind another display object.
LayoutManager
  
sendToBack(target:DisplayObject):void
Send the target display object to bottom most layer.
LayoutManager
  
SetStageReference(st:Stage):void
[static] Set a reference to the stage.
LayoutManager
  
stageAlignBottom(alignMode:String, ... targets):void
Align the target display object to the bottom edge of the stage.
LayoutManager
  
stageAlignBottomCenter(alignMode:String, ... targets):void
Align the target display object to the bottom center of the stage.
LayoutManager
  
stageAlignBottomLeft(alignModeX:String, alignModeY:String, ... targets):void
Align the target display object to the bottom left corner of the stage.
LayoutManager
  
stageAlignBottomRight(alignModeX:String, alignModeY:String, ... targets):void
Align the target display object to the bottom right corner of the stage.
LayoutManager
  
stageAlignCenter(... targets):void
Align the target display object to the dead center of the stage.
LayoutManager
  
stageAlignLeft(alignMode:String, ... targets):void
Align the target display object to the left edge of the stage.
LayoutManager
  
stageAlignMiddleLeft(alignMode:String, ... targets):void
Align the target display object to the left middle of the stage.
LayoutManager
  
stageAlignMiddleRight(alignMode:String, ... targets):void
Align the target display object to the right middle of the stage.
LayoutManager
  
stageAlignRight(alignMode:String, ... targets):void
Align the target display object to the right edge of the stage.
LayoutManager
  
stageAlignTop(alignMode:String, ... targets):void
Align the target display object to the top edge of the stage.
LayoutManager
  
stageAlignTopCenter(alignMode:String, ... targets):void
Align the target display object to the top center of the stage.
LayoutManager
  
stageAlignTopLeft(alignModeX:String, alignModeY:String, ... targets):void
Align the target display object to the top left corner of the stage.
LayoutManager
  
stageAlignTopRight(alignModeX:String, alignModeY:String, ... targets):void
Align the target display object to the top right corner of the stage.
LayoutManager
  
stageAlignXCenter(... targets):void
Align the target display object centered on the x coordinate relatively to the stage.
LayoutManager
  
stageAlignYCenter(... targets):void
Align the target display object centered on the y coordinate relatively to the stage.
LayoutManager
Property detail
ALIGN_INNERproperty
public static var ALIGN_INNER:String = "inner"

An alignment mode that causes the inner edges to be aligned.

ALIGN_OUTERproperty 
public static var ALIGN_OUTER:String = "outer"

An alignment mode that causes the outer edges to be aligned.

containerproperty 
protected var container:DisplayObjectContainer

The container in which layering operations will occur.

ignoreStageAlignproperty 
public static var ignoreStageAlign:Boolean = true

Ignore the stage align property and correctly translate stage alignment operations to the actual stage viewport - meaning if the stage.align property is anything other than undefined or TOP_LEFT, correctly translate the positioning offsets that occur when setting x and y.

StageRefproperty 
public static var StageRef:Stage

a reference to the stage

wholePixelsproperty 
public static var wholePixels:Boolean = true

Whether or not to use whole pixels on for x and y coordinates.

Constructor detail
LayoutManager()constructor
public function LayoutManager(target:DisplayObjectContainer)

Constructor for LayoutManager instances.

Parameters
target:DisplayObjectContainer
Method detail
addChildren()method
public function addChildren(... children):void

Add all children specified to the display list.

Parameters
... children — An array of display objects to add.
addChildrenTo()method 
public function addChildrenTo(target:DisplayObjectContainer, ... children):void

Add all children specified onto the display list of the target container.

Parameters
target:DisplayObjectContainer — A display object to add the spefified children onto.
 
... children — An array of display objects to add.
alignBottom()method 
public function alignBottom(alignMode:String, relativeTo:DisplayObject, ... targets):void

Align a display object to the bottom edge of another display object.

Parameters
alignMode:String — Inner or outer align (default: inner).
 
relativeTo:DisplayObject — The target display object that target will be aligned to.
 
... targets — The target display objects to align.
alignBottomCenter()method 
public function alignBottomCenter(alignMode:String, relativeTo:DisplayObject, ... targets):void

Align a display object to the bottom center of another display object.

Parameters
alignMode:String — Inner or outer align (default: inner).
 
relativeTo:DisplayObject — The target display object that target will be aligned to.
 
... targets — The target display objects to align.
alignBottomLeft()method 
public function alignBottomLeft(alignModeX:String, alignModeY:String, relativeTo:DisplayObject, ... targets):void

Align a display object to the bottom left corner of another display object.

Parameters
alignModeX:String — x-Axis alignment: inner or outer (default: inner).
 
alignModeY:String — y-Axis alignment: inner or outer (default: inner).
 
relativeTo:DisplayObject — The target display object that target will be aligned to.
 
... targets — The target display objects to align.
alignBottomRight()method 
public function alignBottomRight(alignModeX:String, alignModeY:String, relativeTo:DisplayObject, ... targets):void

Align a display object to the bottom right corner of another display object.

Parameters
alignModeX:String — x-Axis alignment: inner or outer (default: inner).
 
alignModeY:String — y-Axis alignment: inner or outer (default: inner).
 
relativeTo:DisplayObject — The target display object to align.
 
... targets — The target display object that target will be aligned to.
alignCenter()method 
public function alignCenter(relativeTo:DisplayObject, ... targets):void

Align a display object to the dead center of another display object.

Parameters
relativeTo:DisplayObject — The target display object that target will be aligned to.
 
... targets — The target display objects to align.
alignColumn()method 
public function alignColumn(options:Object, ... objs):void

Align any objects in a vertical stack (column) on y.

You can supply these options:

Parameters
options:Object — An object with properties (see above).
 
... objs — Rest style list of objects.
alignLeft()method 
public function alignLeft(alignMode:String, relativeTo:DisplayObject, ... targets):void

Align the target display object to the left edge of another display object.

Parameters
alignMode:String — Inner or outer align (default: inner)
 
relativeTo:DisplayObject — The target display object that target will be aligned to.
 
... targets — The target display object to align.
alignMiddleLeft()method 
public function alignMiddleLeft(alignMode:String, relativeTo:DisplayObject, ... targets):void

Align a display object to the left middle of another display object.

Parameters
alignMode:String — Inner or outer align (default: inner).
 
relativeTo:DisplayObject — The target display object that target will be aligned to.
 
... targets — The target display objects to align.
alignMiddleRight()method 
public function alignMiddleRight(alignMode:String, relativeTo:DisplayObject, ... targets):void

Align a display object to the right middle of another display object.

Parameters
alignMode:String — Inner or outer align (default: inner).
 
relativeTo:DisplayObject — The target display object that target will be aligned to.
 
... targets — The target display objects to align.
alignRight()method 
public function alignRight(alignMode:String, relativeTo:DisplayObject, ... targets):void

Align the target display object to the right edge of another display object.

Parameters
alignMode:String — Inner or outer align (default: inner).
 
relativeTo:DisplayObject — The target display object that target will be aligned to.
 
... targets — The target display object to align.
alignTop()method 
public function alignTop(alignMode:String, relativeTo:DisplayObject, ... targets):void

Align a display object to the top edge of another display object.

Parameters
alignMode:String — Inner or outer align (default: inner).
 
relativeTo:DisplayObject — The target display object that target will be aligned to.
 
... targets — The target display object to align.
alignTopCenter()method 
public function alignTopCenter(alignMode:String, relativeTo:DisplayObject, ... targets):void

Align a display object to the top center of another display object.

Parameters
alignMode:String — Inner or outer align (default: inner).
 
relativeTo:DisplayObject — The target display object that target will be aligned to.
 
... targets — The target display objects to align.
alignTopLeft()method 
public function alignTopLeft(alignModeX:String, alignModeY:String, relativeTo:DisplayObject, ... targets):void

Align a display object to the top left corner of another display object.

Parameters
alignModeX:String — x-Axis alignment: inner or outer (default: inner).
 
alignModeY:String — y-Axis alignment: inner or outer (default: inner).
 
relativeTo:DisplayObject — The target display object that target will be aligned to.
 
... targets — The target display objects to align.
alignTopRight()method 
public function alignTopRight(alignModeX:String, alignModeY:String, relativeTo:DisplayObject, ... targets):void

Align a display object to the top right corner of another display object.

Parameters
alignModeX:String — x-Axis alignment: inner or outer (default: inner).
 
alignModeY:String — y-Axis alignment: inner or outer (default: inner).
 
relativeTo:DisplayObject — The target display object that target will be aligned to.
 
... targets — The target display objects to align.
alignXCenter()method 
public function alignXCenter(relativeTo:DisplayObject, ... targets):void

Align the target display object centered on the x coordinate relatively to another display object.

Parameters
relativeTo:DisplayObject — The target display object that target will be aligned to.
 
... targets — The target display object to align.
alignYCenter()method 
public function alignYCenter(relativeTo:DisplayObject, ... targets):void

Align the target display object centered on the y coordinate relatively to another display object.

Parameters
relativeTo:DisplayObject — The target display object that target will be aligned to.
 
... targets — The target display objects to align.
bringForward()method 
public function bringForward(target:DisplayObject):void

Bring a display object forward 1 layer.

Parameters
target:DisplayObject — The target display object.
bringInFront()method 
public function bringInFront(target:DisplayObject, relativeTo:DisplayObject):void

Bring a target display object in front of another display object.

Parameters
target:DisplayObject — The target display object to re-layer.
 
relativeTo:DisplayObject — The display object in which the target will be brought in front of.
bringToFront()method 
public function bringToFront(target:DisplayObject):void

Bring the target display object to the top most layer.

Parameters
target:DisplayObject — The target display object.
dispose()method 
public function dispose():void

Dispose of this layout manager.

getAllChildren()method 
public function getAllChildren(target:Sprite):Array

Returns an array of all the children on the targets display list.

Parameters
target:Sprite — The target display object.

Returns
Array
getStageDeadCenterPoint()method 
public function getStageDeadCenterPoint():Point

Returns the stage dead center point.

Returns
Point
removeAllChildren()method 
public function removeAllChildren():void

Remove all children from the display list.

removeAllChildrenFrom()method 
public function removeAllChildrenFrom(target:DisplayObjectContainer):void

Remove all children from the display list of the specified target object.

Parameters
target:DisplayObjectContainer — The target display object container whose children will be removed.
removeChildren()method 
public function removeChildren(... children):void

Remove all children specified from the display list.

Parameters
... children — The children to remove.
removeChildrenFrom()method 
public function removeChildrenFrom(target:DisplayObjectContainer, ... children):void

Remove specified children from the target DisplayObjectContainer's display list.

Parameters
target:DisplayObjectContainer — A display object to remove the spefified children from.
 
... children — The children to remove.
sendBackward()method 
public function sendBackward(target:DisplayObject):void

Send the target display object backward 1 layer.

Parameters
target:DisplayObject — The target display object.
sendBehind()method 
public function sendBehind(target:DisplayObject, relativeTo:DisplayObject):void

Send a target display object behind another display object.

Parameters
target:DisplayObject — The target display object to re-layer.
 
relativeTo:DisplayObject — The display object in which the target will be moved behind.
sendToBack()method 
public function sendToBack(target:DisplayObject):void

Send the target display object to bottom most layer.

Parameters
target:DisplayObject — The target display object.
SetStageReference()method 
public static function SetStageReference(st:Stage):void

Set a reference to the stage.

Parameters
st:Stage — The stage instance.
stageAlignBottom()method 
public function stageAlignBottom(alignMode:String, ... targets):void

Align the target display object to the bottom edge of the stage.

Parameters
alignMode:String — Inner or outer align (default: inner).
 
... targets — The target display objects to align.
stageAlignBottomCenter()method 
public function stageAlignBottomCenter(alignMode:String, ... targets):void

Align the target display object to the bottom center of the stage.

Parameters
alignMode:String — Inner or outer align (default: inner).
 
... targets — The target display objects to align.
stageAlignBottomLeft()method 
public function stageAlignBottomLeft(alignModeX:String, alignModeY:String, ... targets):void

Align the target display object to the bottom left corner of the stage.

Parameters
alignModeX:String — x-Axis alignment: inner or outer (default: inner).
 
alignModeY:String — y-Axis alignment: inner or outer (default: inner).
 
... targets — The target display objects to align.
stageAlignBottomRight()method 
public function stageAlignBottomRight(alignModeX:String, alignModeY:String, ... targets):void

Align the target display object to the bottom right corner of the stage.

Parameters
alignModeX:String — x-Axis alignment: inner or outer (default: inner).
 
alignModeY:String — y-Axis alignment: inner or outer (default: inner).
 
... targets — The target display objects to align.
stageAlignCenter()method 
public function stageAlignCenter(... targets):void

Align the target display object to the dead center of the stage.

Parameters
... targets — The target display objects to align.
stageAlignLeft()method 
public function stageAlignLeft(alignMode:String, ... targets):void

Align the target display object to the left edge of the stage.

Parameters
alignMode:String — Inner or outer align (default: inner).
 
... targets — The target display objects to align.
stageAlignMiddleLeft()method 
public function stageAlignMiddleLeft(alignMode:String, ... targets):void

Align the target display object to the left middle of the stage.

Parameters
alignMode:String — Inner or outer align (default: inner).
 
... targets — The target display objects to align.
stageAlignMiddleRight()method 
public function stageAlignMiddleRight(alignMode:String, ... targets):void

Align the target display object to the right middle of the stage.

Parameters
alignMode:String — Inner or outer align (default: inner).
 
... targets — The target display objects to align.
stageAlignRight()method 
public function stageAlignRight(alignMode:String, ... targets):void

Align the target display object to the right edge of the stage.

Parameters
alignMode:String — Inner or outer align (default: inner).
 
... targets — The target display objects to align.
stageAlignTop()method 
public function stageAlignTop(alignMode:String, ... targets):void

Align the target display object to the top edge of the stage.

Parameters
alignMode:String — Inner or outer align (default: inner).
 
... targets — The target display objects to align.
stageAlignTopCenter()method 
public function stageAlignTopCenter(alignMode:String, ... targets):void

Align the target display object to the top center of the stage.

Parameters
alignMode:String — Inner or outer align (default: inner).
 
... targets — The target display objects to align.
stageAlignTopLeft()method 
public function stageAlignTopLeft(alignModeX:String, alignModeY:String, ... targets):void

Align the target display object to the top left corner of the stage.

Parameters
alignModeX:String — The target display object to align.
 
alignModeY:String — x-Axis alignment: inner or outer (default: inner).
 
... targets — y-Axis alignment: inner or outer (default: inner).
stageAlignTopRight()method 
public function stageAlignTopRight(alignModeX:String, alignModeY:String, ... targets):void

Align the target display object to the top right corner of the stage.

Parameters
alignModeX:String — x-Axis alignment: inner or outer (default: inner).
 
alignModeY:String — y-Axis alignment: inner or outer (default: inner).
 
... targets — The target display objects to align.
stageAlignXCenter()method 
public function stageAlignXCenter(... targets):void

Align the target display object centered on the x coordinate relatively to the stage.

Parameters
... targets — The target display objects to align.
stageAlignYCenter()method 
public function stageAlignYCenter(... targets):void

Align the target display object centered on the y coordinate relatively to the stage.

Parameters
... targets — The target display objects to align.