Page 1 of 1

List Component's Rows and Icons

PostPosted: Sat Jan 06, 2007 6:54 pm
by Godala
Okay. So with this tutorial, you can make your List Component's every second row to be grey, and other ones white.

Drag new List Component from Library panel, and give it an instance name, 'myList'.
Then just copy and paste this into Actionscript panel.

Code: Select all
myList.setStyle("alternatingRowColors", [0xFFFFFF, 0xEAEAEA]);


So it wasn't so hard...?

Okay, and next thing is adding new colors, for your grey listIcon.
So create new Movieclip and draw rectangle, size: 14x, 14y.

Select your listIcon from your Library, right click on your mouse and select Linkage. There you have to select 'Export in First Frame' and 'Export for Actionscript'. And give it new identifier, 'listIcon'.
And keep it in Library. then go inside of it, and create new Layer, and write this into Actionscript panel.

Code: Select all
var categoryColour = this._parent.item.colour;
colour = new Color(this);
colour.setRGB(categoryColour);


So it's simple code too ;)
Then we just attach them into our List Component's rows. and labels of course. So get back to Scene1 and select your Actions layer and write this into Actionscript panel.

Code: Select all
myList.addItem({label:"Mable", data:1, colour:0x009966});
myList.addItem({label:"Terry", data:2, colour:0xFF3300});
myList.addItem({label:"Saren", data:3, colour:0xEDF176});
myList.addItem({label:"Stead", data:4, colour:0x90C2E9});
myList.addItem({label:"Trent", data:5, colour:0xFF9900});
myList.addItem({label:"Fondue", data:6, colour:0xBCF247});
myList.addItem({label:"Glint", data:7, colour:0xDDF247});
myList.addItem({label:"Rabbit", data:8, colour:0xBC0047});
myList.addItem({label:"Mavis", data:9, colour:0xCCE347});


So now we just created labels, and listIcons colors on there. But next we attach our listIcons into List component with following code.

Code: Select all
myList.defaultIcon = "listIcon";


I hope you understood everything, and if you didn't ask us in here. Or PM me ;) Hope you enjoy so you don't have to create so many listIcons if you want them to be different colors.

PostPosted: Sat Jan 06, 2007 8:06 pm
by simon.shand
cool! thanks Godala!

Re: List Component's Rows and Icons

PostPosted: Wed Dec 12, 2007 8:46 pm
by kentpletcher
Love the tutorial. I'm pretty new to coding so this is very helpful.

I do have a question though. How could I make each name in the list a hyperlink. For instance, if my list is composed of Steve, Larry, John, and Marcy - how can I make a pdf or webpage load when a name is clicked?

This would help me complete my project so any help would be great.

Re: List Component's Rows and Icons

PostPosted: Wed Dec 12, 2007 10:04 pm
by nebutch
Here's a quick example of how you can do that:
Code: Select all
//Add the items to a list
myList.addItem({label:"Google", data:"http://www.google.com"});
myList.addItem({label:"Yahoo", data:"http://www.yahoo.com"});
myList.addItem({label:"You Tube", data:"http://www.youtube.com"});

//Register a listener to your list for a change event
myList.addEventListener("change", myListener);

//Create a listener to receive the event and open your web page
function myListener(evt) {
   getURL(evt.target.selectedItem.data,"_blank");
}

Re: List Component's Rows and Icons

PostPosted: Thu Dec 13, 2007 3:44 pm
by kentpletcher
Thanks so much ... you da' man!

It worked perfectly! Not only webpages but pdf files on my server as well.

I'm indebted to you!

Re: List Component's Rows and Icons

PostPosted: Thu Dec 13, 2007 5:28 pm
by nebutch
No problem ;)