PDA

View Full Version : Listbox customisation



ventoline
July 2nd, 2008, 09:08 AM
Hi,


I'm looking for a way to set the font and the font color inside a listbox....
I've lookes to setStyle, and textformat but it doesn't seem to work...

Please Help!

yaim0310
July 2nd, 2008, 01:57 PM
you were so close too. =P its actually setRendererStyle() and here is an example from the help files:

import fl.controls.List;

var myTextFormat:TextFormat = new TextFormat();
myTextFormat.font = "Comic Sans MS";

var myList:List = new List();
myList.addItem({label:"The quick brown fox..."});
myList.addItem({label:"The quick brown fox..."});
myList.addItem({label:"The quick brown fox..."});
myList.addItem({label:"The quick brown fox..."});
myList.addItem({label:"The quick brown fox..."});
myList.addItem({label:"The quick brown fox..."});
myList.setRendererStyle("textFormat", myTextFormat);
myList.width = 150;
myList.move(10, 10);
addChild(myList);

ventoline
July 3rd, 2008, 10:17 AM
<P><FONT style="BACKGROUND-COLOR: #f5f5ff">here is the code i used, but still doesn't work:</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #f5f5ff"></FONT>&nbsp;</P>
<P><FONT style="BACKGROUND-COLOR: #f5f5ff">var liste:List = new List();</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #f5f5ff">liste.addItem...</FONT></P><FONT style="BACKGROUND-COLOR: #f5f5ff">
<P><FONT style="BACKGROUND-COLOR: #f5f5ff">liste.setRendererStyle("textFormat", "tf");</FONT></P>
<P>liste.width = 100;</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #f5f5ff">liste.move(250,250);</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #f5f5ff">addChild(liste);</FONT></P>
<P><FONT style="BACKGROUND-COLOR: #f5f5ff"></FONT>&nbsp;</P>
<P><FONT style="BACKGROUND-COLOR: #f5f5ff"></FONT>&nbsp;</P>
<P><FONT style="BACKGROUND-COLOR: #f5f5ff">Where do I have it wrong?</FONT></P>

yaim0310
July 3rd, 2008, 10:55 AM
liste.setRendererStyle("textFormat", "tf");

tf should not be a string it should be the TextFormat object, and be sure to make it before setting it to your list
var myTextFormat:TextFormat = new TextFormat();
myTextFormat.font = "Comic Sans MS";
myTextFormat.color = 0x0000FF // blue

liste.setRendererStyle("textFormat", myTextFormat);

ventoline
July 3rd, 2008, 01:54 PM
Thanx, A Lot.

ventoline
July 3rd, 2008, 01:55 PM
pffew, finally working. weid the documentation shows it as ("textFormat", "tf")!!

ventoline
July 4th, 2008, 02:53 PM
Hello, me again!

Now I'm struggling to adjust width and height, and border of cells,

I've looked at setstyle, Cellrenderer.... it doesn't seem to work this way...

anyone knows?

nikefido
July 4th, 2008, 11:25 PM
you don't have to do that programmatically. You can double click the item in your library and edit them. (when you double click, you'll see how they set up the components for you so you can edit them as you wish - it's really neat!)...I'm assuming you are using cs3

Felixz
July 5th, 2008, 09:16 AM
this.list.rowHeight+=3;