简体   繁体   中英

Change AS3 Component Font

I want to change font name, font size and character embedding properties of a component (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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM