Distribution
| Kind of class: | public class |
|---|---|
| Package: | org.casalib.layout |
| Inherits from: | Sprite |
| Version: | 10/26/08 |
| Author: | Aaron Clinger, Jon Adams |
| Classpath: | org.casalib.layout.Distribution |
| File last modified: | Monday, 01 December 2008, 11:16:36 |
Creates the mechanism to distribute DisplayObjects to a vertical or horzontal grid of columns and rows.
Example:
-
package { import flash.display.MovieClip; import flash.display.Sprite; import org.casalib.layout.Distribution; public class MyExample extends MovieClip { public var dist:Distribution; public function MyExample() { super(); this.dist = new Distribution(315); this.dist.setMargin(0, 5, 5, 0); this.addChild(this.dist); var l:uint = 10; var s:Sprite; while (l--) { s = new Sprite(); s.graphics.beginFill(0xFF00FF); s.graphics.drawRect(0, 0, 100, 100); s.graphics.endFill(); this.dist.addChild(s); } this.dist.position(); } } }
Summary
Constructor
- Distribution (size:Number = Number.POSITIVE_INFINITY, isVertical:Boolean = false, snapToPixel:Boolean = true)
- Creates a Distribution.
Instance properties
- marginTop (top:Number) : Number
- The top spacing of the children.
- marginRight (right:Number) : Number
- The right spacing of the children.
- marginBottom (bottom:Number) : Number
- The bottom spacing of the children.
- marginLeft (left:Number) : Number
- The left spacing of the children.
- size (s:Number) : Number
- The maximum width or height of the distrubution.
- vertical (isVertical:Boolean) : Boolean
- Indicates to position children left-to-right top-to-bottom false, or to position children top-to-bottom left-to-right true.
Constructor
Distribution
public function Distribution (
size:Number = Number.POSITIVE_INFINITY,
isVertical:Boolean = false,
snapToPixel:Boolean = true)
Creates a Distribution.
Parameters:
size :
The maximum width or height of the distrubution. If
isVertical argument is false you are setting the width of the distrubution before wrapping, if true you're setting the height before wrapping.isVertical :
Indicates to position children left-to-right top-to-bottom
false, or to position children top-to-bottom left-to-right true.snapToPixel:
Force the position of all children to whole pixels
true, or to let items be positioned on sub-pixels false.Instance properties
marginBottom
public marginBottom:Number
(read,write)
The bottom spacing of the children.
marginLeft
public marginLeft:Number
(read,write)
The left spacing of the children.
marginRight
public marginRight:Number
(read,write)
The right spacing of the children.
marginTop
public marginTop:Number
(read,write)
The top spacing of the children.
size
public size:Number
(read,write)
The maximum width or height of the distrubution. If vertical is
false you are setting the width of the distrubution before wrapping, if true you're setting the height before wrapping. vertical
public vertical:Boolean
(read,write)
Indicates to position children left-to-right top-to-bottom
false, or to position children top-to-bottom left-to-right true. Instance methods
position
public function position (
) : void
Arranges the children of the Distribution.
setMargin
public function setMargin (
top:Number = 0,
right:Number = 0,
bottom:Number = 0,
left:Number = 0) : void
Defines the spacing between children in the distribution.
Parameters:
top :
Sets the top spacing of the children.
right :
Sets the right spacing of the children.
bottom:
Sets the bottom spacing of the children.
left :
Sets the left spacing of the children.