DistributionCollection
| Kind of class: | class |
|---|---|
| Inherits from: | CoreObject |
| Version: | 02/06/07 |
| Author: | Aaron Clinger |
| Classpath: | org.casaframework.layout.DistributionCollection |
| File last modified: | Wednesday, 07 February 2007, 09:40:44 |
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()));
Summary
Constructor
Instance properties
Instance properties inherited from CoreObject
Instance methods
- setRectangle
- getDistributionRectangle
- getBoundingRectangle
- setMargin
- addItem
- removeItem
- update
- destroy
Instance methods inherited from CoreObject
Constructor
DistributionCollection
function DistributionCollection (
)
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.getBoundingRectangle
function getBoundingRectangle (
) : Rectangle
Returns:
Returns the actual area and position the items in the distribution occupy.
getDistributionRectangle
function getDistributionRectangle (
) : Rectangle
Returns:
Returns the area and position of the distribution that was defined with setRectangle.
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.update
function update (
) : Void
Applies the distribution layout for all items added with addItem.
Usage note: