A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: How to load system fonts inside a comboBox in Flash AS3?

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    3

    How to load system fonts inside a comboBox in Flash AS3?

    Hi,

    I am building an application that needs system fonts to be loaded inside a comboBox.

    I am not sure of the exact way of doing.

    Following is the code that loads the system fonts in an array:


    var systemFonts:Array = new Array();
    var fontNames:Array =new Array();

    systemFonts = Font.enumerateFonts(true);
    systemFonts.sortOn("fontName");

    for(var i:int = 0; i < systemFonts.length; i++)
    {
    fontNames.push(systemFonts[i].fontName);
    }


    I wanna know what to do after this so that I can load the fonts inside the comboBox.

    Regards,

    Avi

  2. #2
    Junior Member
    Join Date
    Dec 2009
    Posts
    3

    Got it working

    var systemFonts:Array = new Array();
    systemFonts = Font.enumerateFonts(true);
    systemFonts.sortOn("fontName");
    var font:TextFormat = new TextFormat();
    var dpataProvider = new DataProvider();
    for (var i:int = 0; i < systemFonts.length; i++) {
    dp.addItem({label:systemFonts[i].fontName, data:systemFonts[i]});
    }
    heading_selectfont.dataProvider = dp;
    heading_selectfont.addEventListener(Event.CHANGE, change_font);
    function change_font(event:Event):void
    {
    defaultHeadingFormat.font = heading_selectfont.selectedItem.label;
    template.heading_txt.setTextFormat(defaultHeadingF ormat);
    }

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center