DistributionCollection

Kind of class:class
Inherits from:CoreObject
Version:04/06/07
Author:Aaron Clinger
Classpath:org.casaframework.layout.DistributionCollection
File last modified:Friday, 06 April 2007, 14:20:01
Creates the mechanism to distribute MovieClips, TextFields and Buttons to a vertical or horzontal grid of columns and rows.
Example:
var distribution:DistributionCollection = new DistributionCollection();
this.distribution.setRectangle(new Rectangle(10, 10, 400, Number.POSITIVE_INFINITY));
this.distribution.setMargin(0, 5, 5, 0);

var len:Number = 5;
while (len--) {
    this.distribution.addItem(this.attachMovie("box", "box" + len + "_mc", this.getNextHighestDepth()));
}

this.distribution.positionItems();

Constructor

DistributionCollection

function DistributionCollection (
)
Creates a new DistributionCollection instance.

Instance methods

addItem

function addItem (
item:Object) : Boolean
Adds item to receive distribution position updates.
Parameters:
item:
A MovieClip, TextField or Button.
Returns:
Returns true if item was of type MovieClip, TextField or Button and was successfully added; otherwise false.

destroy

function destroy (
) : Void

getBoundingRectangle

function getBoundingRectangle (
Returns:
Returns the actual area and position the items in the distribution occupy.

getDistributionRectangle

function getDistributionRectangle (
Returns:
Returns the area and position of the distribution that was defined with setRectangle.

positionItems

function positionItems (
) : Void
Applies the distribution layout for all items added with addItem.
Usage note:
positionItems is automatically called after setRectangle and setMargin.

removeItem

function removeItem (
item:Object) : Boolean
Removes item previously added with addItem from receiving distribution updates. Leaves item at its current position.
Parameters:
item:
A MovieClip, TextField or Button you wish to remove.
Returns:
Returns true if item was successfully found and removed; otherwise false.

setMargin

function setMargin (
marginTop:Number, marginRight:Number, marginBottom:Number, marginLeft:Number) : Void
Defines the spacing between items in the distribution.
Parameters:
marginTop :
Sets the top spacing of an element.
marginRight :
Sets the right spacing of an element.
marginBottom:
Sets the bottom spacing of an element.
marginLeft :
Sets the left spacing of an element.

setRectangle

function setRectangle (
rectangle:Rectangle) : Boolean
Defines the area and position of the distribution.
Parameters:
rectangle:
A rectangle defining either the max width or height boundries of the distribution
Returns:
Returns true if the rectangle was valid and applied; otherwise false.
Usage note:
Either the rectangle's width or height must defined as Number.POSITIVE_INFINITY.