Distribution
| Kind of class: | public class |
|---|---|
| Package: | org.casalib.layout |
| Inherits from: | CasaSprite < Sprite |
| Version: | 09/06/09 |
| Author: | Aaron Clinger, Jon Adams |
| Classpath: | org.casalib.layout.Distribution |
| File last modified: | Sunday, 06 September 2009, 09:12:17 |
Creates the mechanism to distribute DisplayObjects to a vertical or horzontal grid of columns and rows.
Example:
-
package { import org.casalib.display.CasaMovieClip; import org.casalib.display.CasaSprite; import org.casalib.layout.Distribution; public class MyExample extends CasaMovieClip { 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:CasaSprite; while (l--) { s = new CasaSprite(); 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 distribution.
- 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.
Instance properties inherited from CasaSprite
Instance methods
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 distribution. If
isVertical argument is false you are setting the width of the distribution 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 distribution. If vertical is
false you are setting the width of the distribution 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.