View Full Version : tree comp + cellRenderer
Hi,
I was wondering if anyone has had any success using the cellRenderer API with the tree component. I've manage to implement the API to a certain extent - but can't figure out how to access the leaf node icons (I want to load my own using loadMovie()). I can access the folder icons programatically with the 'nodeIcon' property, but simply can't get to the leaf nodes.
cancerinform
01-18-2006, 05:22 PM
Have you tried the flash help example?
Hi there,
Yes I've read through the help files.
cancerinform
01-18-2006, 06:26 PM
If you go to "using the cellRenderer API" there is an example;)
hmmm... can you spot which part would reference the leaf icon of the tree comp?
class MultiLineCell extends mx.core.UIComponent
{
var multiLineLabel; //the label to be used for text
var owner; // the row that contains this cell
var listOwner; // the List/grid/tree that contains this cell
// empty constructor
function MultiLineCell()
{
}
// UIObject expects you to fill in createChildren by instantiating
// all the movie clip assets you might need upon initialization.
// Here, it's just a label.
function createChildren():Void
{
// createLabel is a useful method of UIObject--all components use this
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
}
cancerinform
01-18-2006, 06:41 PM
I have not got into that. Just found that tutorial. However, I know from other components that you cannot simply load icon pics using loadMovie. If you can use icons you need to create a movieclip for your icon with linkage identifier and have it in the library. The datagrid component inherits properties from the list component. One of them is
List.iconField
Check the datagrid class or check the example for the list component how to add icons. Hope that helps.
This should have nothing to do with cellRenderer.
> However, I know from other components that you cannot simply load icon pics using loadMovie.
Actually, you can use loadMovie - I've managed to successfully use loadMovie for icons in a cellRenderer for the list, dataGrid and tree components. See the following tutorial for dynamic image loading:
http://www.actionscript.com/Article/tabid/54/ArticleID/displaying-images-in-a-datagrid-utilizing-a-cell-renderer/Default.aspx
The problem I have is that I can't access the default leaf node icon for the tree component.
cancerinform
01-18-2006, 08:07 PM
It's my lucky day today. This is the second new thing I learnt ;) I only used the method I described above so far.
Google:
http://flashmx2004.com/forums/lofiversion/index.php/t7373.html
http://www.sephiroth.it/tutorials/flashPHP/custom_tree/page002.php
May be that helps.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.