【问题标题】:how to load fonts in flex 4.6 windowed application如何在 flex 4.6 窗口应用程序中加载字体
【发布时间】:2013-08-08 07:51:20
【问题描述】:

我有一个在 flex sdk 4.6 中开发的窗口应用程序。我在基于 Web 的应用程序中有相同的版本。在这个应用程序中,我正在加载外部 swf 字体文件。在 Web 应用程序中一切正常,但在窗口应用程序中没有加载字体。

下面是加载字体的代码..

package com
{
    import adobe.utils.CustomActions;

    import flash.display.Loader;
    import flash.display.LoaderInfo;
    import flash.events.Event;
    import flash.events.EventDispatcher;
    import flash.events.IOErrorEvent;
    import flash.net.URLRequest;
    import flash.text.Font;

    import injectors.CentralInjector;

    import mx.core.FontAsset;

    public class LF extends EventDispatcher
    {
        public function LF()
        {

        }
        public function avaliable(style:String):Boolean{
            var embeddedFonts:Array = Font.enumerateFonts(false);           
            for(var i:Number = 0; i < embeddedFonts.length; i++){
                var item:Font = embeddedFonts[i];
                if(item.fontStyle==style){
                    return true;
                }
            }
            return false;
        }
        public function load(url:String):void{
//=====url is http://www.mydomain.com/font1.swf=================
            CustomWaitAlert.show(CustomWaitAlert.WAIT,null,"Loading fonts...");
            var loader:Loader = new Loader();
            var loaderInfo:LoaderInfo = loader.contentLoaderInfo;

            loaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioerror);
            loaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
            loader.load(new URLRequest(url));
        }
        private function ioerror(evt:IOErrorEvent):void{
            this.dispatchEvent(new Event("IOERROR"));
        }
        private function onLoadComplete(evt:Event):void{
            var embeddedFonts:Array = Font.enumerateFonts(false);
            this.dispatchEvent(new Event("COMPLETE"));
            CustomWaitAlert.hide();
        }
    }
}

【问题讨论】:

  • 不,我没有……我已经解决了这个问题。
  • 如果您有解决方案;请回答您自己的问题并将其标记为此类。

标签: apache-flex air flex4.6


【解决方案1】:

我得到的解决方案是首先通过 url 加载器加载字体 swf,然后我们得到 bytearray。之后,只需使用加载器类加载 tge bytearray,加载上下文将 allowcodeimport 设置为 true...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多