0
votes

I Wanted To Load Some Fonts In My SWF Application These Fonts Are Really Fat To Load So It Takes More Time To Load When Needed ...

I have some specific idea --> can i load these fonts before loading my application ? means when my front-page(which is just HTML) is arrives in browser at that time can i load font SWF in backend so that i can use it in application whenever i need :)

specific question is that :- does flex loads fonts in browser cache or flash cache ? and can i use loaded font from another instance of flash player....

if i could load fonts in cache which i have loaded them from another html page and another flash player instance : can save my time

Is the loaded font available to other swf throughtout a web site or just the page the font was loaded on.

enter image description here

2

2 Answers

0
votes

You could embed the fonts inside the flex application, this way the fonts will be downloaded with the SWF file. This way you can easily use them at run time.

For more info: Embed Fonts

[Edit] I would suggest you define the font as a style declaration that you can load at runtime using the styleManager.

var url:String = "/pathTo/otherModule.swf"
var styleManager:IStyleManager2 = mx.styles.StyleManager.getStyleManager(null);
var dispatcher:IEventDispatcher = styleManager.loadStyleDeclarations2(url, true);
dispatcher.addEventListener(StyleEvent.COMPLETE, onReady);
dispatcher.addEventListener(StyleEvent.ERROR, onError);
dispatcher.addEventListener(StyleEvent.PROGRESS, onProgress);
0
votes

How about reducing your file size of the font?

I have never tried it myself, but FontForge seems to be a solution.

Added:

In case reducing the file size is not an option, Runtime Shared Library(RSL) might be the solution you want.

RSLs will be separately downloaded and cached on the client.
(Note that you can also use the external library, but RSL is the much handier version.)

If you are using Flash Builder, you can set it in "Project > Properties > Flex Build Path > Library Path > (Your Library) > Link Type & RSL URL".

You might need to upload 3 files following on your web server

  • swc library which embeds the font file
  • a simple pre-loader application which just links swc as RSL on your webpage
  • your main application that uses font embedded in the swc, which is also linked as RSL

For more information, please refer to the document.