/ / Come caricare i font nell'applicazione a finestre Flex 4.6: flex, air, flex4.6

come caricare i font nell'applicazione con finestre flex 4.6 - flex, air, flex4.6

Ho un'applicazione finestra che ho sviluppatoin flex sdk 4.6. Ho la stessa versione in un'applicazione web based. In questa applicazione sto caricando un file di font swf esterno. Nell'applicazione web tutto funziona correttamente ma il carattere non è caricato nell'applicazione finestra.

Di seguito è riportato il codice per il caricamento dei caratteri.

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();
}
}
}

risposte:

0 per risposta № 1

La soluzione che ho ottenuto è di caricare prima il font swfvia url loader quindi otteniamo il bytearray.after che basta caricare tge bytearray con la classe loader con il contesto di caricamento che sta permettendo allowcodeimport a true ...