Packagefeathers.layout
Classpublic class TiledRowsLayout
InheritanceTiledRowsLayout Inheritance starling.events.EventDispatcher
Implements IVirtualLayout

Positions items as tiles (equal width and height) from left to right in multiple rows. Constrained to the suggested width, the tiled rows layout will change in height as the number of items increases or decreases.

See also

How to use TiledRowsLayout with Feathers containers


Public Properties
 PropertyDefined By
  gap : Number
Quickly sets both horizontalGap and verticalGap to the same value.
TiledRowsLayout
  horizontalAlign : String
If the total row width is less than the bounds, the items in the row can be aligned horizontally.
TiledRowsLayout
  horizontalGap : Number
The horizontal space, in pixels, between tiles.
TiledRowsLayout
  padding : Number
Quickly sets all padding properties to the same value.
TiledRowsLayout
  paddingBottom : Number
The space, in pixels, below the items.
TiledRowsLayout
  paddingLeft : Number
The space, in pixels, to the left of the items.
TiledRowsLayout
  paddingRight : Number
The space, in pixels, to the right of the items.
TiledRowsLayout
  paddingTop : Number
The space, in pixels, above of items.
TiledRowsLayout
  paging : String
If the total combined height of the rows is larger than the height of the view port, the layout will be split into pages where each page is filled with the maximum number of rows that may be displayed without cutting off any items.
TiledRowsLayout
  requestedColumnCount : int
Requests that the layout uses a specific number of columns in a row, if possible.
TiledRowsLayout
  requestedRowCount : int
Requests that the layout uses a specific number of rows, if possible.
TiledRowsLayout
  requiresLayoutOnScroll : Boolean
[read-only] Determines if the container calls layout() when the scroll position changes.
TiledRowsLayout
  resetTypicalItemDimensionsOnMeasure : Boolean
If set to true, the width and height of the typicalItem will be reset to typicalItemWidth and typicalItemHeight, respectively, whenever the typical item needs to be measured.
TiledRowsLayout
  tileHorizontalAlign : String
If the item's width is less than the tile bounds, the position of the item can be aligned horizontally.
TiledRowsLayout
  tileVerticalAlign : String
If an item's height is less than the tile bounds, the position of the item can be aligned vertically.
TiledRowsLayout
  typicalItem : DisplayObject
Used internally by a component that supports layout virtualization, such as List, to provide a display object with dimensions that represent a "typical" item in the layout.
TiledRowsLayout
  typicalItemHeight : Number
Used to reset the height, in pixels, of the typicalItem for measurement.
TiledRowsLayout
  typicalItemWidth : Number
Used to reset the width, in pixels, of the typicalItem for measurement.
TiledRowsLayout
  useSquareTiles : Boolean
Determines if the tiles must be square or if their width and height may have different values.
TiledRowsLayout
  useVirtualLayout : Boolean
Determines if virtual layout should be used.
TiledRowsLayout
  verticalAlign : String
If the total column height is less than the bounds, the items in the column can be aligned vertically.
TiledRowsLayout
  verticalGap : Number
The vertical space, in pixels, between tiles.
TiledRowsLayout
Public Methods
 MethodDefined By
  
Constructor.
TiledRowsLayout
  
calculateScrollPositionForIndex(index:int, items:Vector.<DisplayObject>, x:Number, y:Number, width:Number, height:Number, result:Point = null, nearest:Boolean = false, scrollX:Number = 0, scrollY:Number = 0):Point
TiledRowsLayout
  
getNearestScrollPositionForIndex(index:int, scrollX:Number, scrollY:Number, items:Vector.<DisplayObject>, x:Number, y:Number, width:Number, height:Number, result:Point = null):Point
Calculates the scroll position nearest to the current scroll position that will display the full bounds of the item within the view port.
TiledRowsLayout
  
getScrollPositionForIndex(index:int, items:Vector.<DisplayObject>, x:Number, y:Number, width:Number, height:Number, result:Point = null):Point
Using the item dimensions, calculates a scroll position that will ensure that the item at a given index will be visible within the specified bounds.
TiledRowsLayout
  
getVisibleIndicesAtScrollPosition(scrollX:Number, scrollY:Number, width:Number, height:Number, itemCount:int, result:Vector.<int> = null):Vector.<int>
Used internally by a component, such as List, to determines which indices are visible with the specified view port bounds and scroll position.
TiledRowsLayout
  
layout(items:Vector.<DisplayObject>, viewPortBounds:ViewPortBounds = null, result:LayoutBoundsResult = null):LayoutBoundsResult
Positions (and possibly resizes) the supplied items within the optional bounds argument.
TiledRowsLayout
  
measureViewPort(itemCount:int, viewPortBounds:ViewPortBounds = null, result:Point = null):Point
Used internally by a component, such as List, to measure the view port based on the typical item dimensions or cached dimensions, if available.
TiledRowsLayout
Events
 Event Summary Defined By
  Dispatched when a property of the layout changes, indicating that a redraw is probably needed.TiledRowsLayout
Public Constants
 ConstantDefined By
  HORIZONTAL_ALIGN_CENTER : String = center
[static] If the total item width is smaller than the width of the bounds, the items will be aligned to the center.
TiledRowsLayout
  HORIZONTAL_ALIGN_LEFT : String = left
[static] If the total item width is smaller than the width of the bounds, the items will be aligned to the left.
TiledRowsLayout
  HORIZONTAL_ALIGN_RIGHT : String = right
[static] If the total item width is smaller than the width of the bounds, the items will be aligned to the right.
TiledRowsLayout
  PAGING_HORIZONTAL : String = horizontal
[static] The items will be positioned in pages horizontally from left to right.
TiledRowsLayout
  PAGING_NONE : String = none
[static] The items will not be paged.
TiledRowsLayout
  PAGING_VERTICAL : String = vertical
[static] The items will be positioned in pages vertically from top to bottom.
TiledRowsLayout
  TILE_HORIZONTAL_ALIGN_CENTER : String = center
[static] If an item width is smaller than the width of a tile, the item will be aligned to the center of the tile.
TiledRowsLayout
  TILE_HORIZONTAL_ALIGN_JUSTIFY : String = justify
[static] The item will be resized to fit the width of the tile.
TiledRowsLayout
  TILE_HORIZONTAL_ALIGN_LEFT : String = left
[static] If an item width is smaller than the width of a tile, the item will be aligned to the left edge of the tile.
TiledRowsLayout
  TILE_HORIZONTAL_ALIGN_RIGHT : String = right
[static] If an item width is smaller than the width of a tile, the item will be aligned to the right edge of the tile.
TiledRowsLayout
  TILE_VERTICAL_ALIGN_BOTTOM : String = bottom
[static] If an item height is smaller than the height of a tile, the item will be aligned to the bottom edge of the tile.
TiledRowsLayout
  TILE_VERTICAL_ALIGN_JUSTIFY : String = justify
[static] The item will be resized to fit the height of the tile.
TiledRowsLayout
  TILE_VERTICAL_ALIGN_MIDDLE : String = middle
[static] If an item height is smaller than the height of a tile, the item will be aligned to the middle of the tile.
TiledRowsLayout
  TILE_VERTICAL_ALIGN_TOP : String = top
[static] If an item height is smaller than the height of a tile, the item will be aligned to the top edge of the tile.
TiledRowsLayout
  VERTICAL_ALIGN_BOTTOM : String = bottom
[static] If the total item height is smaller than the height of the bounds, the items will be aligned to the bottom.
TiledRowsLayout
  VERTICAL_ALIGN_MIDDLE : String = middle
[static] If the total item height is smaller than the height of the bounds, the items will be aligned to the middle.
TiledRowsLayout
  VERTICAL_ALIGN_TOP : String = top
[static] If the total item height is smaller than the height of the bounds, the items will be aligned to the top.
TiledRowsLayout
Property Detail
gapproperty
gap:Number

Quickly sets both horizontalGap and verticalGap to the same value. The gap getter always returns the value of horizontalGap, but the value of verticalGap may be different.

The default value is 0.


Implementation
    public function get gap():Number
    public function set gap(value:Number):void

See also

horizontalAlignproperty 
horizontalAlign:String

If the total row width is less than the bounds, the items in the row can be aligned horizontally.

The default value is TiledRowsLayout.HORIZONTAL_ALIGN_CENTER.


Implementation
    public function get horizontalAlign():String
    public function set horizontalAlign(value:String):void

See also

horizontalGapproperty 
horizontalGap:Number

The horizontal space, in pixels, between tiles.

The default value is 0.


Implementation
    public function get horizontalGap():Number
    public function set horizontalGap(value:Number):void
paddingproperty 
padding:Number

Quickly sets all padding properties to the same value. The padding getter always returns the value of paddingTop, but the other padding values may be different.

The default value is 0.


Implementation
    public function get padding():Number
    public function set padding(value:Number):void

See also

paddingBottomproperty 
paddingBottom:Number

The space, in pixels, below the items.

The default value is 0.


Implementation
    public function get paddingBottom():Number
    public function set paddingBottom(value:Number):void
paddingLeftproperty 
paddingLeft:Number

The space, in pixels, to the left of the items.

The default value is 0.


Implementation
    public function get paddingLeft():Number
    public function set paddingLeft(value:Number):void
paddingRightproperty 
paddingRight:Number

The space, in pixels, to the right of the items.

The default value is 0.


Implementation
    public function get paddingRight():Number
    public function set paddingRight(value:Number):void
paddingTopproperty 
paddingTop:Number

The space, in pixels, above of items.

The default value is 0.


Implementation
    public function get paddingTop():Number
    public function set paddingTop(value:Number):void
pagingproperty 
paging:String

If the total combined height of the rows is larger than the height of the view port, the layout will be split into pages where each page is filled with the maximum number of rows that may be displayed without cutting off any items.

The default value is TiledRowsLayout.PAGING_NONE.


Implementation
    public function get paging():String
    public function set paging(value:String):void

See also

requestedColumnCountproperty 
requestedColumnCount:int

Requests that the layout uses a specific number of columns in a row, if possible. Set to 0 to calculate the maximum of columns that will fit in the available space.

If the view port's explicit or maximum width is not large enough to fit the requested number of columns, it will use fewer. If the view port doesn't have an explicit width and the maximum width is equal to Number.POSITIVE_INFINITY, the width will be calculated automatically to fit the exact number of requested columns.

If paging is enabled, this value will be used to calculate the number of columns in a page. If paging isn't enabled, this value will be used to calculate a minimum number of columns, even if there aren't enough items to fill each column.

The default value is 0.


Implementation
    public function get requestedColumnCount():int
    public function set requestedColumnCount(value:int):void
requestedRowCountproperty 
requestedRowCount:int

Requests that the layout uses a specific number of rows, if possible. If the view port's explicit or maximum height is not large enough to fit the requested number of rows, it will use fewer. Set to 0 to calculate the number of rows automatically based on width and height.

If paging is enabled, this value will be used to calculate the number of rows in a page. If paging isn't enabled, this value will be used to calculate a minimum number of rows, even if there aren't enough items to fill each row.

The default value is 0.


Implementation
    public function get requestedRowCount():int
    public function set requestedRowCount(value:int):void
requiresLayoutOnScrollproperty 
requiresLayoutOnScroll:Boolean  [read-only]

Determines if the container calls layout() when the scroll position changes. Useful for transforming items as the view port scrolls. This value should be true for layouts that implement the IVirtualLayout interface and the useVirtualLayout property is set to true. May also be used by layouts that toggle item visibility as the items scroll into and out of the view port.


Implementation
    public function get requiresLayoutOnScroll():Boolean
resetTypicalItemDimensionsOnMeasureproperty 
resetTypicalItemDimensionsOnMeasure:Boolean

If set to true, the width and height of the typicalItem will be reset to typicalItemWidth and typicalItemHeight, respectively, whenever the typical item needs to be measured. The measured dimensions of the typical item are used to fill in the blanks of a virtualized layout for virtual items that don't have their own display objects to measure yet.

The default value is false.


Implementation
    public function get resetTypicalItemDimensionsOnMeasure():Boolean
    public function set resetTypicalItemDimensionsOnMeasure(value:Boolean):void

See also

tileHorizontalAlignproperty 
tileHorizontalAlign:String

If the item's width is less than the tile bounds, the position of the item can be aligned horizontally.

The default value is TiledRowsLayout.TILE_HORIZONTAL_ALIGN_CENTER.


Implementation
    public function get tileHorizontalAlign():String
    public function set tileHorizontalAlign(value:String):void

See also

tileVerticalAlignproperty 
tileVerticalAlign:String

If an item's height is less than the tile bounds, the position of the item can be aligned vertically.

The default value is TiledRowsLayout.TILE_VERTICAL_ALIGN_MIDDLE.


Implementation
    public function get tileVerticalAlign():String
    public function set tileVerticalAlign(value:String):void

See also

typicalItemproperty 
typicalItem:DisplayObject

Used internally by a component that supports layout virtualization, such as List, to provide a display object with dimensions that represent a "typical" item in the layout. These dimensions will be used to fill in blanks for the layout when an item is virtual and isn't actually on the display list. If you are simply passing a layout to a component, setting this property will have no effect. It is meant to be used by the component, and the component will replace any value you pass to this property.


Implementation
    public function get typicalItem():DisplayObject
    public function set typicalItem(value:DisplayObject):void
typicalItemHeightproperty 
typicalItemHeight:Number

Used to reset the height, in pixels, of the typicalItem for measurement. The measured dimensions of the typical item are used to fill in the blanks of a virtualized layout for virtual items that don't have their own display objects to measure yet.

This value is only used when resetTypicalItemDimensionsOnMeasure is set to true. If resetTypicalItemDimensionsOnMeasure is set to false, this value will be ignored and the typicalItem dimensions will not be reset before measurement.

If typicalItemHeight is set to NaN, the typical item will auto-size itself to its preferred height. If you pass a valid Number value, the typical item's height will be set to a fixed size. May be used in combination with typicalItemWidth.

The default value is NaN.


Implementation
    public function get typicalItemHeight():Number
    public function set typicalItemHeight(value:Number):void

See also

typicalItemWidthproperty 
typicalItemWidth:Number

Used to reset the width, in pixels, of the typicalItem for measurement. The measured dimensions of the typical item are used to fill in the blanks of a virtualized layout for virtual items that don't have their own display objects to measure yet.

This value is only used when resetTypicalItemDimensionsOnMeasure is set to true. If resetTypicalItemDimensionsOnMeasure is set to false, this value will be ignored and the typicalItem dimensions will not be reset before measurement.

If typicalItemWidth is set to NaN, the typical item will auto-size itself to its preferred width. If you pass a valid Number value, the typical item's width will be set to a fixed size. May be used in combination with typicalItemHeight.

The default value is NaN.


Implementation
    public function get typicalItemWidth():Number
    public function set typicalItemWidth(value:Number):void

See also

useSquareTilesproperty 
useSquareTiles:Boolean

Determines if the tiles must be square or if their width and height may have different values.

The default value is true.


Implementation
    public function get useSquareTiles():Boolean
    public function set useSquareTiles(value:Boolean):void
useVirtualLayoutproperty 
useVirtualLayout:Boolean

Determines if virtual layout should be used. Some components don't support virtual layouts, and they will always change this property to false. In those cases, the virtual layout options will be ignored.

The default value is true.


Implementation
    public function get useVirtualLayout():Boolean
    public function set useVirtualLayout(value:Boolean):void
verticalAlignproperty 
verticalAlign:String

If the total column height is less than the bounds, the items in the column can be aligned vertically.

The default value is TiledRowsLayout.VERTICAL_ALIGN_TOP.


Implementation
    public function get verticalAlign():String
    public function set verticalAlign(value:String):void

See also

verticalGapproperty 
verticalGap:Number

The vertical space, in pixels, between tiles.

The default value is 0.


Implementation
    public function get verticalGap():Number
    public function set verticalGap(value:Number):void
Constructor Detail
TiledRowsLayout()Constructor
public function TiledRowsLayout()

Constructor.

Method Detail
calculateScrollPositionForIndex()method
public function calculateScrollPositionForIndex(index:int, items:Vector.<DisplayObject>, x:Number, y:Number, width:Number, height:Number, result:Point = null, nearest:Boolean = false, scrollX:Number = 0, scrollY:Number = 0):Point

Parameters

index:int
 
items:Vector.<DisplayObject>
 
x:Number
 
y:Number
 
width:Number
 
height:Number
 
result:Point (default = null)
 
nearest:Boolean (default = false)
 
scrollX:Number (default = 0)
 
scrollY:Number (default = 0)

Returns
Point
getNearestScrollPositionForIndex()method 
public function getNearestScrollPositionForIndex(index:int, scrollX:Number, scrollY:Number, items:Vector.<DisplayObject>, x:Number, y:Number, width:Number, height:Number, result:Point = null):Point

Calculates the scroll position nearest to the current scroll position that will display the full bounds of the item within the view port. If the item is already fully displayed in the view port, the current scroll position will be returned unchanged.

While the item will be displayed in the view port without being clipped in any way, it may not be placed in the most prominent position possible. To give the item a more prominent location, use getScrollPositionForIndex() instead.

This function should always be called after the layout() function. The width and height arguments are the final bounds of the view port, which may be calculated in the layout() function.

Parameters

index:int
 
scrollX:Number
 
scrollY:Number
 
items:Vector.<DisplayObject>
 
x:Number
 
y:Number
 
width:Number
 
height:Number
 
result:Point (default = null)

Returns
Point
getScrollPositionForIndex()method 
public function getScrollPositionForIndex(index:int, items:Vector.<DisplayObject>, x:Number, y:Number, width:Number, height:Number, result:Point = null):Point

Using the item dimensions, calculates a scroll position that will ensure that the item at a given index will be visible within the specified bounds.

Typically, this function is used to show the item in the most prominent way, such as centering. To scroll a minimum distance required to display the full bounds of the item in the view port, use getNearestScrollPositionForIndex() instead.

This function should always be called after the layout() function. The width and height arguments are the final bounds of the view port, which may be calculated in the layout() function.

Parameters

index:int
 
items:Vector.<DisplayObject>
 
x:Number
 
y:Number
 
width:Number
 
height:Number
 
result:Point (default = null)

Returns
Point
getVisibleIndicesAtScrollPosition()method 
public function getVisibleIndicesAtScrollPosition(scrollX:Number, scrollY:Number, width:Number, height:Number, itemCount:int, result:Vector.<int> = null):Vector.<int>

Used internally by a component, such as List, to determines which indices are visible with the specified view port bounds and scroll position. Indices that aren't returned are typically not displayed and can be replaced virtually. Uses the typical items dimensions, or cached dimensions, if available.

This function is meant to be called by the List or other component that uses the virtual layout. If you're simply creating a layout for a List or another component, do not call this function. It is meant for developers creating custom components only.

Parameters

scrollX:Number
 
scrollY:Number
 
width:Number
 
height:Number
 
itemCount:int
 
result:Vector.<int> (default = null)

Returns
Vector.<int>
layout()method 
public function layout(items:Vector.<DisplayObject>, viewPortBounds:ViewPortBounds = null, result:LayoutBoundsResult = null):LayoutBoundsResult

Positions (and possibly resizes) the supplied items within the optional bounds argument. If no bounds are specified, the layout algorithm will assume that the bounds start a 0,0 and have unbounded dimensions. Returns the actual bounds of the content, which may be different than the specified bounds.

Note: The items are not absolutely restricted to appear only within the bounds. The bounds can affect positioning, but the algorithm may very well ignore them completely.

If a layout implementation needs to access accurate width and height values from items that are of type IFeathersControl, it must call validate() manually. For performance reasons, the container that is the parent of the items will not call validate() before passing the items to a layout implementation. Meeting this requirement may be as simple as looping through the items at the beginning of layout() and validating all items that are Feathers UI controls:

         const itemCount:int = items.length;
         for(var i:int = 0; i < itemCount; i++)
         {
             var item:IFeathersControl = items[i] as IFeathersControl;
             if(item)
             {
                 item.validate();
             }
         }

Parameters

items:Vector.<DisplayObject>
 
viewPortBounds:ViewPortBounds (default = null)
 
result:LayoutBoundsResult (default = null)

Returns
LayoutBoundsResult
measureViewPort()method 
public function measureViewPort(itemCount:int, viewPortBounds:ViewPortBounds = null, result:Point = null):Point

Used internally by a component, such as List, to measure the view port based on the typical item dimensions or cached dimensions, if available.

This function is meant to be called by the List or other component that uses the virtual layout. If you're simply creating a layout for a List or another component, do not call this function. It is meant for developers creating custom components only.

Parameters

itemCount:int
 
viewPortBounds:ViewPortBounds (default = null)
 
result:Point (default = null)

Returns
Point
Event Detail
change Event
Event Object Type: starling.events.Event
Event.type property = starling.events.Event.CHANGE

Dispatched when a property of the layout changes, indicating that a redraw is probably needed.

The properties of the event object have the following values:

PropertyValue
bubblesfalse
currentTargetThe Object that defines the event listener that handles the event. For example, if you use myButton.addEventListener() to register an event listener, myButton is the value of the currentTarget.
datanull
targetThe Object that dispatched the event; it is not always the Object listening for the event. Use the currentTarget property to always access the Object listening for the event.

Constant Detail
HORIZONTAL_ALIGN_CENTERConstant
public static const HORIZONTAL_ALIGN_CENTER:String = center

If the total item width is smaller than the width of the bounds, the items will be aligned to the center.

See also

HORIZONTAL_ALIGN_LEFTConstant 
public static const HORIZONTAL_ALIGN_LEFT:String = left

If the total item width is smaller than the width of the bounds, the items will be aligned to the left.

See also

HORIZONTAL_ALIGN_RIGHTConstant 
public static const HORIZONTAL_ALIGN_RIGHT:String = right

If the total item width is smaller than the width of the bounds, the items will be aligned to the right.

See also

PAGING_HORIZONTALConstant 
public static const PAGING_HORIZONTAL:String = horizontal

The items will be positioned in pages horizontally from left to right.

See also

PAGING_NONEConstant 
public static const PAGING_NONE:String = none

The items will not be paged. In other words, they will be positioned in a continuous set of rows without gaps.

See also

PAGING_VERTICALConstant 
public static const PAGING_VERTICAL:String = vertical

The items will be positioned in pages vertically from top to bottom.

See also

TILE_HORIZONTAL_ALIGN_CENTERConstant 
public static const TILE_HORIZONTAL_ALIGN_CENTER:String = center

If an item width is smaller than the width of a tile, the item will be aligned to the center of the tile.

See also

TILE_HORIZONTAL_ALIGN_JUSTIFYConstant 
public static const TILE_HORIZONTAL_ALIGN_JUSTIFY:String = justify

The item will be resized to fit the width of the tile.

See also

TILE_HORIZONTAL_ALIGN_LEFTConstant 
public static const TILE_HORIZONTAL_ALIGN_LEFT:String = left

If an item width is smaller than the width of a tile, the item will be aligned to the left edge of the tile.

See also

TILE_HORIZONTAL_ALIGN_RIGHTConstant 
public static const TILE_HORIZONTAL_ALIGN_RIGHT:String = right

If an item width is smaller than the width of a tile, the item will be aligned to the right edge of the tile.

See also

TILE_VERTICAL_ALIGN_BOTTOMConstant 
public static const TILE_VERTICAL_ALIGN_BOTTOM:String = bottom

If an item height is smaller than the height of a tile, the item will be aligned to the bottom edge of the tile.

See also

TILE_VERTICAL_ALIGN_JUSTIFYConstant 
public static const TILE_VERTICAL_ALIGN_JUSTIFY:String = justify

The item will be resized to fit the height of the tile.

See also

TILE_VERTICAL_ALIGN_MIDDLEConstant 
public static const TILE_VERTICAL_ALIGN_MIDDLE:String = middle

If an item height is smaller than the height of a tile, the item will be aligned to the middle of the tile.

See also

TILE_VERTICAL_ALIGN_TOPConstant 
public static const TILE_VERTICAL_ALIGN_TOP:String = top

If an item height is smaller than the height of a tile, the item will be aligned to the top edge of the tile.

See also

VERTICAL_ALIGN_BOTTOMConstant 
public static const VERTICAL_ALIGN_BOTTOM:String = bottom

If the total item height is smaller than the height of the bounds, the items will be aligned to the bottom.

See also

VERTICAL_ALIGN_MIDDLEConstant 
public static const VERTICAL_ALIGN_MIDDLE:String = middle

If the total item height is smaller than the height of the bounds, the items will be aligned to the middle.

See also

VERTICAL_ALIGN_TOPConstant 
public static const VERTICAL_ALIGN_TOP:String = top

If the total item height is smaller than the height of the bounds, the items will be aligned to the top.

See also