开发者

Is it possible to use `[Embed source=`... with Flash CS3?

Is it possible to do the following using AS3 and Flash CS3 IDE? The following only works if the txt TextField is created in the IDE and if the txt.embedFonts line is removed. This does not work if I create a TextField with AS3 instead of using the IDE. Is embedding a font via code only available in Flex?

package mtm.EmbedFonts
{
    import flash.display.MovieClip;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.text.AntiAliasType;
    import flash.text.TextFieldAutoSize;

    public class EmbedFonts extends MovieClip
    {
        public var txt:TextField; //References stage instance created in Flash CS3 IDE
        [Embed(source='C:/WINDOWS/Fonts/Arial.TTF', fontName='_Arial', unicodeRange='U+0020-U+002F,U+0030-U+0039,U+003A-U+0040,U+0041-U+005A,U+005B-U+0060,U+0061-U+007A,U+007B-U+007E')]
        protected var format:TextFormat = new TextFormat();

        public function EmbedFonts():void
        {   
            initTextFormat();
            initTextField();
            txt.text = 'Hello World!';
        }

        protected function initTextFormat():void
        {
            format.letterSpacing = 1;
            format.size = 14;
            format.font = "Arial";
        }

        protected function initTextField():void
        {
            txt.multiline = true;
            txt.wordWrap = true;
            txt.border = true;
            txt.selectable = true;
            txt.autoSize = TextFieldAutoSize.LEFT;
            txt.condenseWhite = true;
            txt.embedFonts = true;
  开发者_运维知识库          txt.setTextFormat(format);
            txt.antiAliasType = AntiAliasType.ADVANCED;
        }
    }
}


The [Embed] metatag is only available in Flex sadly.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜