03-03-2006, 03:25 AM
|
#1
|
|
Registered User
Join Date: Jan 2006
Posts: 45
|
CellRenderer example please?
Can someone point out or post a good example of using a CellRenderer in a List please? Every example I've found, including Macromedia's, just does not explain it very well. I've been using cell renderers for a long time in Java Swing, so I'm familiar with how it works in theory, but for some reason ActionScripts's version of it is just not clicking with me.
My current use of it requires displaying an icon, and a bit of text, for an array of objects that holds several fields. But I just cannot see how to make it actually display anything, all I get is a blank field (which is still selectable).
Thanks.
|
|
|
03-03-2006, 12:10 PM
|
#2
|
|
Off-Line
Join Date: Aug 2004
Location: Ibiza/Spain language :Hungarian/German/ abit English
Posts: 6,539
|
|
|
|
03-07-2006, 02:35 PM
|
#3
|
|
Registered User
Join Date: Jan 2006
Posts: 45
|
Quote:
|
Originally Posted by Xeef
|
Yeah, I've read this and looked over the example code several times, but it just doesn't make any sense. First, there isn't a simple demonstration of a single column list to look at, only datagrids, and I don't see where the value to display gets from the array into the cell object to render. Does the renderer's setValue() just intuit the proper field to display? What about in the more complex example with the combobox and checkbox? I'm just not finding detailed enough documentation from Macromedia or anywhere else on how this works.
Thanks,
Dan
|
|
|
03-07-2006, 02:58 PM
|
#4
|
|
Off-Line
Join Date: Aug 2004
Location: Ibiza/Spain language :Hungarian/German/ abit English
Posts: 6,539
|
Quote:
|
Does the renderer's setValue() just intuit the proper field to display?
|
yes ( sortof )
each field has a function "setValue" wich is called then
Quote:
|
and I don't see where the value to display gets from the array into the cell object to render
|
here :
setValue(suggestedValue:String, item:Object, selected:Boolean)
item is the object whit the values
eg.
item.MyValue
item.MycheckboxValue
....
|
|
|
03-07-2006, 03:24 PM
|
#5
|
|
Registered User
Join Date: Jan 2006
Posts: 45
|
Quote:
|
Originally Posted by Xeef
yes ( sortof )
each field has a function "setValue" wich is called then
here :
setValue(suggestedValue:String, item:Object, selected:Boolean)
item is the object whit the values
eg.
item.MyValue
item.MycheckboxValue
....
|
Ok, so when I want to add my object into the Array, I would use
addItem({field1:value, field2:value})
Then in setValue() I can retrieve those fields using
item.field1
item.field2
?
I've found that I'm not able to trace() from my cellrenderer class, is that normal or is there some other way to check values while in there?
Thanks for all the help,
Dan
|
|
|
03-07-2006, 03:29 PM
|
#6
|
|
Off-Line
Join Date: Aug 2004
Location: Ibiza/Spain language :Hungarian/German/ abit English
Posts: 6,539
|
you shoud by abel to trace from the class if not there is something wrong !
|
|
|
03-07-2006, 06:31 PM
|
#7
|
|
Registered User
Join Date: Jan 2006
Posts: 45
|
Quote:
|
Originally Posted by Xeef
you shoud by abel to trace from the class if not there is something wrong !
|
So I see-- I put traces in the Macromedia cellrendering example (combobox & checkbox cells in a datagrid) and they output fine. I get nothing in my own single column List cellrenderer though. I don't know what it could be though, I started off with the MultiLineCell example and began customizing from there. I set it with list.cellRenderer = myCellRenderer. Is it done some different way?
Thanks,
Dan
|
|
|
03-07-2006, 07:08 PM
|
#8
|
|
Supa Flasha
Join Date: May 2004
Location: Atlanta, GA
Posts: 504
|
Here's a good example:
http://www.flash-db.com/Tutorials/ce...erer/index.php
Remember, the DataGrid class extends the List class. So it's essentially going to be done the same way for both. The difference being that List components only have one column where DataGrid components can have more than one. You may also want to take a look at this thread as well.
Last edited by Scottae; 03-07-2006 at 07:13 PM.
|
|
|
03-07-2006, 07:41 PM
|
#9
|
|
Off-Line
Join Date: Aug 2004
Location: Ibiza/Spain language :Hungarian/German/ abit English
Posts: 6,539
|
list.cellRenderer = myCellRenderer
myCellRenderer needs to by a STRING whit the library identifier of the clip linked to the cellrendererClass
|
|
|
03-07-2006, 09:43 PM
|
#10
|
|
Registered User
Join Date: Jan 2006
Posts: 45
|
Quote:
|
Originally Posted by Xeef
list.cellRenderer = myCellRenderer
myCellRenderer needs to by a STRING whit the library identifier of the clip linked to the cellrendererClass
|
Oops, I did mean the string. I'm starting to think somehow my custom cell renderer simply is not being used, and my list.cellRenderer = "myCellRenderer" is just setting an undefined renderer. I put it in an external .as file, found in the same folder as the fla, and it contains all of the MultiLineCell.as example code. Isn't that enough, or is there something else I must do?
Ah, is it necessary to setup the class for exporting using the Linkage Properties dialog as well?
Last edited by danimal; 03-07-2006 at 09:46 PM.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 12:55 PM.
///
|
|