KoolMoves AS3 API Documentation | All Packages | All Classes | Index | Frames No Frames |
Class SimpleTable

Package | km.display
Class | public class SimpleTable
Inheritance | SimpleTable flash.display.Sprite

The SimpleTable class.

Example

    import km.components.*;
    import km.display.*;
    import km.skins.*;

    function fn(cell:SimpleTableCell):void {
     cell.content = new LabelButton();
     cell.content.label.text = 'Cell ' + cell.col + ',' + cell.row;
     ScriptedSkin.applyTo(cell.content);
    }

    var table:SimpleTable = new SimpleTable();
    table.onCellCreate = fn;
    table.setSize(300, 160);
    table.move(20, 20);
    table.colWidths = [.25, .25, .25, .25];
    table.rowHeights = [.25, .25, .25, .25];
    table.cellPadding = 3;
    table.cell(1,0).span(2,1);
    table.update();

    addChild(table);

Public Properties

| Property | Defined by
--- | --- | ---
|  | background : BitmapData Table background image. | SimpleTable
|  | bgColor : uint Table background color [ARGB]. | SimpleTable
|  | borderColor : uint ARGB cell border color [ARGB]. | SimpleTable
|  | cellPadding : int Cell padding [px] | SimpleTable
|  | colCount : int [read-only] Gets the number of columns. | SimpleTable
|  | colWidths : Array Gets or sets the array of column widths. To calculate the width of a column, the following formula is used : colWidths[col] / totalColWidths[] * tableWidth | SimpleTable
|  | contentSetSize : Boolean = true Boolean value indicating if a setSize function of the cell content object should be called when the table is rendered. | SimpleTable
|  | height : Number | SimpleTable
|  | onCellCreate : Function A function expecting one variable (cell:SimpleTableCell) that can be set that is called when a cell is created. | SimpleTable
|  | onCellRender : Function A function expecting one variable (cell:SimpleTableCell) that can be set that is called when a cell is rendered. | SimpleTable
|  | rowCount : int [read-only] Gets the number of rows. | SimpleTable
|  | rowHeights : Array Gets or sets the array of row heights. To calculate the height of a row, the following formula is used : rowHeight[row] / totalRowHeights[] * tableHeight | SimpleTable
|  | width : Number | SimpleTable

Public Methods

| Method | Defined by
--- | --- | ---
|  | SimpleTable(tableWidth:int = 0, tableHeight:int = 0, columns:int = 0, rows:int = 0) | SimpleTable
|  | cell(col:int, row:int):SimpleTableCell Get a table cell. | SimpleTable
|  | clearCells():void Clears all table cells. | SimpleTable
|  | move(x:int, y:int):void Move the table. | SimpleTable
|  | setSize(tableWidth:int, tableHeight:int, columns:int = 0, rows:int = 0):void Sets the table size. | SimpleTable
|  | update():void Updates the table. | SimpleTable

Property detail

background | property

`public var background:BitmapData`

Table background image.

bgColor | property |

`public var bgColor:uint`

Table background color [ARGB].

borderColor | property |

`public var borderColor:uint`

ARGB cell border color [ARGB].

cellPadding | property |

`public var cellPadding:int`

Cell padding [px]

colCount | property |

`colCount:int` [read-only]

Gets the number of columns.

Implementation
`public function get colCount():int`

colWidths | property |

`colWidths:Array` [read-write]

Gets or sets the array of column widths.
To calculate the width of a column, the following formula is used : colWidths[col] / totalColWidths[] * tableWidth

Implementation
`public function get colWidths():Array`
`public function set colWidths(value:Array):void`

contentSetSize | property |

`public var contentSetSize:Boolean = true`

Boolean value indicating if a setSize function of the cell content object should be called when the table is rendered.

height | property |

`height:Number` [read-write]

Implementation
`public function get height():Number`
`public function set height(value:Number):void`

onCellCreate | property |

`public var onCellCreate:Function`

A function expecting one variable (cell:SimpleTableCell) that can be set that is called when a cell is created.

onCellRender | property |

`public var onCellRender:Function`

A function expecting one variable (cell:SimpleTableCell) that can be set that is called when a cell is rendered.

rowCount | property |

`rowCount:int` [read-only]

Gets the number of rows.

Implementation
`public function get rowCount():int`

rowHeights | property |

`rowHeights:Array` [read-write]

Gets or sets the array of row heights.
To calculate the height of a row, the following formula is used : rowHeight[row] / totalRowHeights[] * tableHeight

Implementation
`public function get rowHeights():Array`
`public function set rowHeights(value:Array):void`

width | property |

`width:Number` [read-write]

Implementation
`public function get width():Number`
`public function set width(value:Number):void`
Constructor detail

SimpleTable | () | constructor

`public function SimpleTable(tableWidth:int = 0, tableHeight:int = 0, columns:int = 0, rows:int = 0)`

Parameters

| `tableWidth:int` (default = `0`)``
| `tableHeight:int` (default = `0`)``
| `columns:int` (default = `0`)``
| `rows:int` (default = `0`)``

Method detail

cell | () | method

`public function cell(col:int, row:int):SimpleTableCell`

Get a table cell.

Parameters

| `col:int`
| `row:int`

Returns

| `SimpleTableCell`

clearCells | () | method |

`public function clearCells():void`

Clears all table cells.

move | () | method |

`public function move(x:int, y:int):void`

Move the table.

Parameters

| `x:int`
| `y:int`

setSize | () | method |

`public function setSize(tableWidth:int, tableHeight:int, columns:int = 0, rows:int = 0):void`

Sets the table size.

Parameters

| `tableWidth:int`
| `tableHeight:int`
| `columns:int` (default = `0`)``
| `rows:int` (default = `0`)``

update | () | method |

`public function update():void`

Updates the table.

Last update : 04/05/2008