So I’ve gotten a few questions about how to place custom icons in the List component, like the ones on the gotoAndLearn() site. So here is the code block that I use. The instance name of my List component is “tl” in this case:
[as]tl.iconFunction = function(item) {
if(item.data.indexOf(“aftereffects”)!=-1) return “ae”;
if(item.data.indexOf(“flash”)!=-1) return “flashIcon”;
if(item.data.indexOf(“swift”)!=-1) return “swiftIcon”;
if(item.data.indexOf(“photoshop”)!=-1) return “photoshopIcon”;
}[/as]
The List component has an event called “iconFunction” that you will need to set up. It is called when the List is instantiated and it calls it for every item in the list. Each time it sends the item and you need to define a parameter to catch it. I used “item” in the above example. Then you simply do some checking to determine what icon is appropriate for that item, and return it. In the above code you will see that I have four different icon MovieClips in my library called “ae”, “flashIcon”, “swiftIcon”, and “photoshopIcon.” Make sure to set up the linkage ID for your MovieClips.
But lets say that you only need one icon for all of the items in the list. Then your “iconFunction” definition would look like:
[as]tl.iconFunction = function(item) {
return “yourIconMovieClip”;
}[/as]
Lee








Is there any way to dinamycaly load the icons. This linked from library is really a disadvantage
It’s quite simple to dynamically load the icons. I did it with xml and a loadFiles function I wrote to get the directory contents of $_GET variable. This was a PHP page that generated the script. I then used an xml load function to populate the list box and function contents as Jeremy has demonstrated above. Hope that helps.
Any quick and easy way to get the list component in Flash 8 to have a transparent background?
something with setStyle or as, versus having to drill down and find what the background is and reskin it?
I made the whole thing’s alpha 0, but that ditches the scrollbar also…
Is there any way that a video tutorial could be made. I am simply not getting this. Can these icons be loaded dynamically through XML???
Thanks.
I second Eddy’s request – I’m having a real problem with this as well. Anyone have any advice?
I read your blog in a regular manner and just love it
hope there will be more postings from you, keep on going
greetz, terry
I was working on a custom list which uses external image references.
I got stuck but found a simply way to use external files when using a custom icon with a List component.
Create your list with AS2 code, and define your data provider.
When you do, remember to add a attribute for the external image source.
E.g. your_list_name.addItem{label:”your label”, data:”your data”, icon:”your_linkage_id”, image:”external_reference_url”}
Open your library and edit the symbol (“your_instance_name”) that you are using for the icon. Remember to define the “linkage id” in the properties of the symbol.
Create a placeholder movieclip inside the symbol used for the icon (“your_instance_name”) and give it an instance name.
Add the following code to load in your external image.
” your_placeholder_instance_name.loadMovie( _parent.item.image ); ”
Pretty simple.
Hey Bernard is there any chance you could post a source file example of that? It’s exactly what I need to do but I’m stuck so obviously I’m doing something wrong. A working example would be greatly appreciated.
Hi , um facing a problem in palcing a buttom in the list items to get a better view and nice action , i mean i want to show the list items as list of buttons not the boring viw of the ordinary list component . any one can help ..