سؤال

I have a window application that i have developed in flex sdk 4.6 . I have the same version in web based application. In this application i am loading external swf font file. In web application everything is working fine but font is not loaded in window application.

Below is the code for loading the fonts..

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();
        }
    }
}
هل كانت مفيدة؟

المحلول

The solution i got is to first load the font swf via url loader then we get the bytearray.after that just load tge bytearray with the loader class with loading context which is having allowcodeimport sets to true...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top