ActionScript 2.0 Components Language Reference |
|
|
|
| CellRenderer API > CellRenderer.setSize() | |||
Flash Player 6 (6.0.79.0).
Flash MX 2004.
componentInstance.setSize(width,height)
width A number that indicates the width at which to lay out the component.
height A number that indicates the height at which to lay out the component.
Nothing.
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.
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;
}
|
|
|
|