开发者

How do I make a custom Flash component work with any font?

开发者 https://www.devze.com 2023-03-14 03:18 出处:网络
So we have a component we have written ourselves that deals with text display and translation between languages, reading translations from a file. Ideally what we would like to do is have this compone

So we have a component we have written ourselves that deals with text display and translation between languages, reading translations from a file. Ideally what we would like to do is have this component be compatible with any font we can embed in the main .swf's library. What's the best way to do that?

Currently we are going down the route of having our component have an attribute for the font name, lets say 'Font1'. We drag the component into the .FLA file we want and then add a new font to the library called 'Font1' and set it to the typeface we wa开发者_如何学JAVAnt. This is proving to be inconsistent and problematic which implies it's not really an ideal way of doing it.

Is there anyway to achieve the feature we want? The key is flexibility, we want to easily support languages (hence the component) but we don't want design to be limited in their font selection. Its not practical to embed a range of fonts in the component for example, as it adds to file size and is restrictive.

Any ideas or solutions to this much appreciated. The component is written in AS3 and we are using Flash CS4.


Look into Runtime font loading or runtime font embedding. There are many ways to deal with this depending on your development environment. In that regard, FlashBuilder may offer you more flexibility than Flash CS4 actually.

A general approach could be to have a set of SWFs file, each embedded with a particular font. Of course, these SWFs shouldn't be loaded at start up.

When calling a font in your component, you would practically call a function that would load the corresponding SWF, adding the font to your Application Domain, therefore making it available to your component.

Here's an article that may help in clarifying the process
http://nochump.com/blog/archives/20

but a Google search such as Runtime font loading or embedding should bring out a lot more resources.

Hope this helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号