views:

1494

answers:

2

Using CS4, how do I set the font of a List control? I tried this:

  var myFormat:TextFormat = new TextFormat();
  myFormat.font = config.settings["list font name"];
  myFormat.size = Number(config.settings["list font size"]);
  list.setStyle("textFormat", myFormat);

No dice.

+1  A: 

You can set styles by instance, class and globally.

For selectable lists(List,ComboBox,TileList,etc.), you need to use setRendererStyle instead of setStyle, because you're setting styles for each cell renderer/item, not the list itself, if that makes sense:

list.setRendererStyle('textFormat',myFormat);

Also you can use global styles using StyleManager.

Make sure your fonts is embedded first, then try

import fl.managers.StyleManager;

var myFormat:TextFormat = new TextFormat(config.settings["list font name"],config.settings["list font size"]);
StyleManager.setStyle('embedFonts',true);
StyleManager.setStyle('textFormat',myFormat);
George Profenza
+1  A: 

This took me a long time to figure out, sadly:
http://help.adobe.com/en_US/AS3LCR/Flash_10.0/fl/controls/SelectableList.html#setRendererStyle()

Will Mavis
thanx a lot =)!
DataGreed