CellRenderer.getPreferredWidth()

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX 2004.

Usage

componentInstance.getPreferredWidth()

Parameters

None.

Returns

A value (of type Number) that indicates the correct width of the cell.

Description

Method; the preferred width of a cell. If you specify a width greater than that of the component, the cell may be cut off.

Implement this method for the Menu component. Your cell is sized to whatever the width of the row is, except in a menu, which must measure the text for the width of the row. You can also implement this method for the DataGrid component where the header renderer checks whether or not to show the sort arrow.

Example

This example returns the value multiplied by 3, which indicates that the cell should be three times bigger than the length of the string it is rendering:

function getPreferredWidth():Number
{
   return myString.length*3;
}

This example comments out the getPreferredWidth() method:

// function getPreferredWidth :: only for a menu or datagrid