开发者

Change AS3 Component Font

I want to change font name, font size and character embedding properties of a c开发者_如何学Goomponent (Combobox in my case) through Flash IDE (not in action script). Is there an option to do that?

Thanks.


No, you need to use ActionScript to do that. Here is how I do it:

package com.twoa.ui.base.controls {
    import fl.controls.ComboBox;
    import fl.controls.List;
    import flash.text.Font;
    import flash.text.TextFormat;

    public class MyComboBox extends ComboBox {

        private var textFormat:TextFormat;
        private var textFormat2:TextFormat;

        public function MyComboBox() {
            super();
            forceStyle();
        }

        public function forceStyle() {

            var f:Font = new Interface();

            var textFormat:TextFormat = new TextFormat()
            textFormat.size = 8;
            textFormat.color = 0xffffff;
            textFormat.font = f.fontName

            var textFormat2:TextFormat = new TextFormat()
            textFormat2.size = 8;
            textFormat2.color = 0xffffff;
            textFormat2.font = f.fontName

            dropdown.setRendererStyle("embedFonts", true);
            dropdown.setRendererStyle("textFormat", textFormat);

            textField.setStyle("embedFonts", true);
            textField.setStyle("textFormat", textFormat2);

        }

    }
}


It looks that there is no way to skin font of default flash components. I ended up writing my own.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜