Welcome, Guest. Please login or register.
Did you miss your activation email?
05/23/12, 02:21
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  Flash MX 2004 (Moderators: Flash-db, Musicman, vesa kortelainen, Ronald Wernecke, Andresss, papachan)
| | |-+  CellRenderer that resizes rowHeight to content of cell
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: CellRenderer that resizes rowHeight to content of cell  (Read 1265 times)
hugobossv8
Jr. Programmer
**
Posts: 63



View Profile WWW
« on: 04/29/04, 18:27 »

Hi,

I've been trying to get the MultiLineCell Renderer below to automatically resize the height of rows based on content of row.  I've had no luck so far.  Any ideas anyone?

I got this from liveDocs a Nigel post:

http://livedocs.macromedia.com/flash/mx2004/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004_Documentation&file=04_com55.htm
[script]
class MultiLineCell extends mx.core.UIComponent
{
var multiLineLabel; // : TextField - the label we're going to use for text.
var owner; // The row that contains this cell
var listOwner; // the List/grid/tree that contains this cell

function MultiLineCell()
{

}

// UIObject expects you to fill in createChildren by instantiating
// all the movie clip assets you might need upon initialization.
// for us, it's just a label.
function createChildren(Void) : Void
{
// createLabel is a useful method of UIObject - all components use this
var c = multiLineLabel = createLabel("multiLineLabel", 0);
//don't worry too much about this - it links the style of the label to the
//style of the grid itself
c.styleName = listOwner;
c.selectable = false;
c.tabEnabled = false;
c.background = false;
c.border = false;
c.multiline = true;
c.wordWrap = true;
//added to autosize this field
c.autosize = true;
}

// note that, by extending UIComponent, we get setSize for free
// however, UIComponent expects us to implement size().
// Assume __width and __height are set for us now.
// We're going to grow the cell to fit the whole rowHeight
function size(Void) : Void
{
// __width and __height are the underlying variables of the getter
// setters .width and .height. Not strictly kosher, but I'm fond of small
// performance shortcuts in cases where it's reasonably safe.
var c = multiLineLabel;
c._width = __width;
c._height = __height;
}

function getPreferredHeight(Void) : Number
{
//k, a little voodoo here. we know the cell will be given a property, "owner",
// which will be the row. We always prefer that the cell take up most of the row's height
return owner.__height - 4;
}

function setValue(suggested:String, item:Object, selected:Boolean) : Void
{
//not much to do here. Feed the label!
multiLineLabel.text = suggested;
}

//function getPreferredWidth :: only really necessary for menu
}
[/script]
« Last Edit: 04/29/04, 18:30 by hugobossv8 » Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything