Using embedded fonts with the Flash CS3 ComboBox control

The following example shows how you can use embedded fonts with a Flash CS3 ComboBox control’s drop down menu.

Full code after the jump.

The following example requires a ComboBox control in your library as well as an embedded font in your library with a linkage identifier of “VerdanaEmbedded” and a normal font weight.

import fl.controls.ComboBox;import fl.data.DataProvider;var font:Font = new VerdanaEmbedded() as Font;var tf:TextFormat = new TextFormat();tf.font = font.fontName;var arr:Array = new Array();arr.push({label:"One"});arr.push({label:"Two"});arr.push({label:"Three"});arr.push({label:"Four"});arr.push({label:"Five"});arr.push({label:"Six"});var cb:ComboBox = new ComboBox();cb.dropdown.setRendererStyle("embedFonts", true);cb.dropdown.setRendererStyle("textFormat", tf);cb.dataProvider = new DataProvider(arr);cb.move(10, 10);addChild(cb);

Update:

If you want to add anti-aliased text to the main ComboBox itself (and not just the dropdown menu), you can use the setStyle() method to set the embedFonts and textFormat styles on the textInput property, as seen in the following snippet:

var cb:ComboBox = new ComboBox();cb.textField.setStyle("embedFonts", true);cb.textField.setStyle("textFormat", tf);cb.dropdown.setRendererStyle("embedFonts", true);cb.dropdown.setRendererStyle("textFormat", tf);cb.dataProvider = new DataProvider(arr);cb.move(10, 10);addChild(cb);