PDA

View Full Version : CellRenderer for MultiLine List Component


RooTShell
08-31-2006, 06:45 PM
Hey guys...

I've been strugling in trying to make a list component in Flash 8 to have multiline labels... Been trying to do it with the cellrenderer method without success...

Can anyone post an example on how to do it? I've been looking at few examples but they all are for the datagrid and combobox component, none of them I was able to make them work with the list component.

Thanks in advance!

RooTShell

sleekdigital
09-11-2006, 11:39 PM
http://download.macromedia.com/pub/documentation/en/flash/fl8/MultiLineCellRenderer.zip

is linked from this page...
http://www.adobe.com/support/documentation/en/flash/fl8/samples.html#component_samples

RooTShell
09-15-2006, 03:46 PM
http://download.macromedia.com/pub/documentation/en/flash/fl8/MultiLineCellRenderer.zip

is linked from this page...
http://www.adobe.com/support/documentation/en/flash/fl8/samples.html#component_samples

Thanks for the reply! I've already looked at the example but that's for the DataGrid component, can't make it work for the combobox. Am I missing something?

bruzed
10-12-2006, 09:22 PM
Hi!
I have exactly the same problem. :mad:
I tried out the sample on the list component. The fields do get populated but with comma separations and no line breaks! That's not what I want.
Aren't there any examples on how to do this??? :confused:
Please help
Thanks in advance!

Mazoonist
10-12-2006, 11:51 PM
I have successfully done this. I just followed the help files. It requires you to create a class file called MultilineCell.AS (all I did was copied and pasted their code into a file and saved it!). Then you have to create a movie clip in your FLA that has linkage ID set for the class file, and set it as the cell renderer in the code. Also, you have to increase the rowHeight of the List Component so that your multi-line text will fit. Also, note the use of the "\n" inside the strings to make a new line. Finally, to access the List Component part of the Combo Box, you refer to it using the "dropdown" property.

I've included the file "MultilineCell.AS" in the ZIP I'm uploading. There is also an example FLA file. Keep both files in the same folder. Try running the FLA file. There is a combo box and a list box that should both exhibit the multi-line cell behavior.

Hope that helps. :)

bruzed
10-13-2006, 07:24 AM
Thanks, Mazoonist!
It's looking good. Unfortunately it isn't exactly what I want to implement :(
I need to display the list something like this: http://www.kirupa.com/developer/actionscript/multiDimArrays_attach.htm
Any ideas on how that could happen?

Thanks in advance for any help!!!

Mazoonist
10-13-2006, 12:02 PM
Hey, bruzed,

Well, it may not be what you're looking for, but it seemed like the answer to the original question.

It would be good to have a better idea of what you exactly want to do. Do you want to have a list that looks just like Kirupa's? There are a few issues here:

1. Making all the data come from an array.
2. Formatting the text differently on the different lines
3. Including a clickable Link or Button.

One is easy, two's a pain, three's next to impossible (and to me goes against the grain of what the component was designed to do). However, on three, you could program the whole list item to go to a certain web page when clicked.

In fact, the whole thing would be easier to accomplish without using the list component. So that makes me wonder, what's the advantage of using the list component? Is it because you get scroll bars? If so, you should consider using the scrollPane instead. You can load anything you want to in the scrollPane--just build a movie clip (either authoring time or dynamically) and give it to the scrollPane as its contentPath.

bruzed
10-16-2006, 11:24 PM
Hey Mazoonist,

It sounds fair enough to use the scrollpane to show this data. I do want it exactly like the one on Kirupa, it also has some additional text fields. Do you know where to find an example to do this? I can't seem to figure it out.
Sorry, I'm relatively new to this stuff.

Thanks for your patience and help!!

Mazoonist
10-17-2006, 12:38 AM
Hey bruzed,

No, I don't know where to find a tutorial, but I did put something together for you. First, I did the Kirupa tutorial. That's saved as kirupa.fla.

Here's what scrollPane can use as it's contentPath:
1. A movie clip in the library, set to export with a linkage ID.
2. An external SWF file.

Since I want this to be as dynamic as possible, option 1 is kind of "out." I can't create a movie clip in the library, as I won't know exactly what size to make it to hold all the entries there might be. Therefore I chose option 2.

(The only change I made to the kirupa file was to make the initial X and Y locations both 0, because that'll work better with the scrollPane).

I created a second file, callled it "kirupa2," and it's the file that's got the scrollpane in it. It's really very simple, I just dragged a scrollPane component from the components panel into the document. I sized it to 300 pixels wide, and gave it an instance name (myScroller), but I purposely made it a little short in height, so you could see the vertical scrollbar in action. By the way, to size the component, you just use the free transform tool on it.

The scrollPane has a property called "contentPath." All you need to do is set scrollPane's contentPath equal to something (see 1 & 2 above), and bingo!, content will apppear in the scrollPane. There are two ways to set this contentPath property: Using actionscript, or using the component inspector. I chose the actionscript route (you'll find it on frame 1 of the actions layer in kirupa2.fla); this is the command that does it:

myScroller.contentPath = "kirupa.swf";

Yes, it really is that simple. :) Hope that helps. Hopefully you've got Flash 8, if not, let me know and I'll resend it in MX 2004 format.