views:

39

answers:

1

Hello All,

After a lot of experiments and reading many articles, Q&As, I still didn't find the answers to my problem, then I decided to ask my question at great stackoverflow forum:-)

The setup of my project is as follows: - Create an AS3 project in Flash Builder 4 (Main.as3proj), and write source code in it; - Create graphical assets in Flash CS5; - Load the graphical assets in the AS3 project;

In the graphical assets (swfs), there are text fields, we would like to use Embedded fonts for the text fields. But we don't want to embed the fonts in all swfs, we want to create a swf as a font library (FontLib.swf), that embed all the fonts needed across all the graphical assets (swfs).

After loading or embedding the FontLib.swf to the main application (Main.swf), the embedded fonts is availabe:

TextField.isFontCompatible(myFontName, myFont)

is true. And when I create a TextField with the embedded font at runtime, it works fine.

But besides this, I want to use the embedded fonts for the TextFields in other graphical assets like what I described at the begging, but when I try to change the text for the dynamic text field in a movie clip, the text field will disappear. (Before changing the text, it can be displayed because Flash CS5 automatically embed the fonts for the characters already input in the fla/swf file).

I tried to clone the text field with the same properties of the text field in the movie clip and replaced the old one, as I said, this works as other text fields created at run time. But I have other problem with cloning and replacing the text fields in movie clip.

I wonder if there is a way to instruct the flash player to use the externally loaded embedded fonts for the text fields in movie clip.

A: 

In the CS5 IDE :

  • Select the textfield with the font you want embedded.
  • Selected Embed... to open theFont Embedding dialogue.
  • In the right-hand side panel select the ActionScript tab.
  • At the very bottom under the heading Sharing check the box that says Import for runtime sharing
  • Inside the textfield that says URL you enter a url pointing to the SWF file where you have embedded the font.

Now the SWF with the embedded font that you specified in the url will automatically be loaded by the flash player.

cmann
Thanks cmann for the answer, but do you mean I have to import the swf containing the shared embedded font for every swf containing the textfield using embedded font? Is there a way to load the FontLib.swf once in the main application, and use the embedded fonts in other swfs?
FlyingDreamer
I'm not sure I fully understand you, but in every file that uses the font you will have to point it to your font library swf - in the URL property in the font dialog you will enter 'FontLib.swf'. The flash player should only load this once and then cache it.
cmann
Yes, this method works for me, thanks a lot! The only thing puzzles me is, in Adobe's documentation, the URL can only be "http://..." or "https://...". In my test, using relative path like "../shared/FontLib.swf" works, but is there any problem if I publish the project at a certain website in the future?
FlyingDreamer
The url can be relative "../shared/FontLib.swf" or absolute "http://" as long as the file it points to exists. The relative path will work no matter where you move your project as long as you keep the same directory structure.
cmann
Thank you, cmann!
FlyingDreamer