User Guide
CellRenderer API 151
Usage
componentInstance.getPreferredHeight()
Parameters
None.
Returns
The correct height for the cell.
Description
Method; returns the preferred height of a cell. This is especially important for getting the right
height of text within the cell. If you set this value higher than the
rowHeight property of the
component, cells will bleed above and below the rows.
This method is not provided by the List class; you must implement it. It tells the rows of the list
how to center the cell and how to adjust the cell’s height if necessary. If necessary, you can return
a constant (for example, 22), or you can measure and return the height of the contents. You can
also return
owner.height, which is the height of the row.
Example
This example returns the value 20, which indicates that the cell should be 20 pixels high:
function getPreferredHeight(Void) :Number
{
return 20;
}
This example returns a value that is 4 pixels less that the height of the row:
function getPreferredHeight():Number
{
/* You know the cell is given a property, "owner", which is the row. It’s
always preferred for the cell to take up most of the row's height.
*/
return owner.__height - 4;
}
CellRenderer.getPreferredWidth()
Availability
Flash Player 6 (6.0 79.0).
Edition
Flash MX 2004.
Usage
componentInstance.getPreferredWidth()
Parameters
None.