是否可以使用`[嵌入源=`...与Flash CS3?

时间:2010-07-26 23:31:09

标签: flash actionscript-3 fonts embed

是否可以使用AS3和Flash CS3 IDE执行以下操作?以下仅适用于在IDE中创建txt TextField且删除txt.embedFonts行的情况。如果我使用AS3而不是使用IDE创建TextField,则不起作用。是否仅通过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;
        }
    }
}

1 个答案:

答案 0 :(得分:1)

[Embed] metatag仅在Flex中可用。