var c = multiLineLabel = createLabel("multiLineLabel", 10);
// 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;
}
// 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 getter/setters .width and .height
var c = multiLineLabel;
c._width = __width;
c._height = __height;
}
function getPreferredHeight():Number
{
/* The cell is given a property, "owner",
that references the row. It's always preferred
that the cell take up most of the row's height.
*/
return owner.__height - 4;
}
function setValue(suggested:String, item:Object, selected:Boolean):Void
{
// Set the text property of the label
// You could also set the text property to a variable.
multiLineLabel.text = "This text wraps to two lines!";
}
// function getPreferredWidth :: only necessary for menu
// function getCellIndex :: not used in this cell renderer
// function getDataLabel :: not used in this cell renderer
}
Methods to implement for the CellRenderer API
You must write a class with the following methods so that the List, DataGrid, Tree, or Menu
component can communicate with the cell.
Method
CellRenderer.getPreferredHeight()
CellRenderer.getPreferredWidth()
148
Chapter 6: Components Dictionary
Description
Returns the preferred height of a cell.
The preferred width of a cell.
Need help?
Do you have a question about the FLASH MX 2004-USING COMPONENTS and is the answer not in the manual?