User Guide

Using the CellRenderer API 113
private var owner; // The row that contains this cell.
private var listOwner; // The List, data grid or tree containing this
cell.
// Cell height offset from the row height total and preferred cell
width.
private static var PREFERRED_HEIGHT_OFFSET = 4;
private static var PREFERRED_WIDTH = 100;
// Starting depth.
private var startDepth:Number = 1;
// Constructor. Should be empty.
public function MultiLineCell()
{
}
/* UIObject expects you to fill in createChildren by instantiating all
the movie clip assets you might need upon initialization. In this case
we are creating one label*/
public function createChildren():Void
{
// The createLabel method is a useful method of UIObject and a handy
// way to make labels in components.
var c = multiLineLabel = this.createLabel("multiLineLabel",
startDepth);
// Links the style of the label to the style of the grid
c.styleName = listOwner;
c.selectable = false;
c.tabEnabled = false;
c.background = false;
c.border = false;
c.multiline = true;
c.wordWrap = true;
}
public function size():Void
{
/* By extending UIComponent which imports UIObject, you get setSize
automatically, 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. The rowHeight itself is a
property of the list type component that we are rendering a cell in.
Since we want the rowHeight to fit two lines, when creating the list
type component using this cellRenderer class, make sure its rowHeight
property is set large enough that two lines of text can render within
it.*/
/*__width and __height are the underlying variables of the getter/
setters .width and .height.*/
var c = multiLineLabel;