User Guide

124 CellRenderer API
Description
Method; lets the list tell its cells the size at which they should lay themselves out. The cell
renderer should do layout so that it fits in the specified area, or the cell may bleed into other
parts of the list and appear broken.
If the cell renderer extends the UIObject class, you should implement the size() method
instead. Write the same function that you would write for
setSize(), but use the width and
height properties instead of parameters.
Example
The following example sizes an image in the cell to fit within the bounds specified by the list:
function setSize(w:Number, h:Number):Void
{
image._width = w-2;
image._height = h-2;
image._x = image._y = 1;
}
This example is in a cell renderer class that extends UIComponent (which extends UIObject),
so you must implement
size() instead of setSize(), as follows:
// By extending UIComponent, you get setSize for free;
// however, UIComponent expects you to implement size().
// Assume __width and __height are set for you now.
// You’re going to expand the cell to fit the whole rowHeight.
function size():Void
{
// __width and __height are the underlying variables
// of the getters/setters .width and .height.
var c = multiLineLabel;
c._width = __width;
c._height = __height;
}
CellRenderer.setValue()
Availability
Flash Player 6 (6.0.79.0).
Edition
Flash MX 2004.
Usage
componentInstance.setValue(suggested, item, selected)