Because of this scrolling behavior, you cannot expect a cell to be used for only one value.
Recycling of rows means that the cell renderer must know how to completely reset its state when
it is set to a new value. For example, if your cell renderer creates an icon to display one item, it
might need to remove that icon when another item is rendered with it. Assume your cell renderer
is a container that will be filled with numerous item values over time, and it has to know how to
completely change itself from displaying one value to displaying another. In fact, your cell should
even know how to properly render undefined items, which might mean removing all old content
in the cell.
Using the CellRenderer API
You must write a class with four methods (
CellRenderer.getPreferredWidth()
CellRenderer.setValue()
The class must be specified in the AS 2.0 Class text box in the Linkage Properties dialog box of a
movie clip symbol in your Flash application. You can look at the CheckCellRenderer class that
implements the Cell Renderer API for an example; it's located in FirstRun/classes/mx/controls/
cells.
There are two methods and a property (
CellRenderer.getDataLabel()
to a cell to allow it to communicate with the list-based component. For example, suppose a cell
contains a check box that, when selected, causes a row to be selected. The cell renderer needs a
reference to the list-based component that contains it in order to call the component's
selectedIndex
so that it can set
CellRenderer.listOwner
implement these ActionScript elements; the cell receives them automatically when it is placed in
the list-based component.
146
Chapter 6: Components Dictionary
) that the list-based component uses to communicate with the cell.
, and
property. Also, the cell needs to know which item index it is currently rendering
to the correct number; the cell can use
selectedIndex
and
CellRenderer.getCellIndex()
CellRenderer.getPreferredHeight()
,
CellRenderer.setSize()
CellRenderer.getCellIndex()
CellRenderer.listOwner
,
, and
,
) that are given automatically
to do so. You do not need to
Need help?
Do you have a question about the FLASH MX 2004-USING COMPONENTS and is the answer not in the manual?