Flash: How to share embedded fonts with text fields in multiple movie clips
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开发者_JAVA百科 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.
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.
I had the same problem, I changed the font of my movieClip textfield as an ordinary textfield in the application but it didn't dsplay my new text. I had to add Font.registerfont(myfont) so the embedded font in my application is shared to the movieclip swf.
精彩评论