1 Reply Latest reply on Jun 13, 2007 3:54 PM by wsinglis

    Dynamic Selection of Fonts

    wsinglis
      Using AS2, I was able to develop a combo box that contained a list of the fonts installed on the end user's computer using TextField.getFontList().sort(). With AS3, I have tried to do the same thing with Font.enumerateFonts(true) as described on the Class Font page with no success. I do get an array of the font objects but I can't seem to get to the fontName or any of the information that was available with the AS2.

      How do I get into get a combo box that will show the font's name and, when selected, return the proper font property to change text in a text field?
        • 1. Re: Dynamic Selection of Fonts
          wsinglis Level 1
          This is fantastic. As soon as I posted this, an answer presented itself. The following works. I will spend a little time cleaning it up but there it is.

          var allFonts:Array = new Array();
          allFonts = Font.enumerateFonts(true);
          allFonts.sortOn("fontName", Array.CASEINSENSITIVE);
          var allFontsName:Array = new Array();
          for(c=0; c<allFonts.length; c++) {
          allFontsName.push(allFonts[c].fontName);
          }
          var allFontDP:DataProvider = new DataProvider(allFontsName);
          font_cb.dataProvider = allFontDP;