Setting the name and font size in an AS3 list control (flash.controls.List)

Using CS4, how to 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.

+3
source share
2 answers

You can set styles by instance, class, and globally.

For selected lists (List, ComboBox, TileList, etc.) you need to use setRendererStyle instead of setStyle , because you set styles for each rendering element / cell element, not the list itself, if that makes sense:

list.setRendererStyle('textFormat',myFormat);

You can also use global styles using the StyleManager .

, ,

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);
+3

Source: https://habr.com/ru/post/1711373/


All Articles