Using an External Font

I have this swf that loads a lot of things from others swfs and they all use a non-default font. After searching ways to embedded this font into only one file and currently that’s what I have:

  • a class that loads the font Class from a swf
  • a function that receives a TextField as parameter and change it’s font to the loaded one
  • a function that iterates over all objects in stage :open_mouth: looking for text fields and pass them to the above function

So this is half way done, but I’m stuck at two problems.

First, it’s obviously slow to iterate over all display objects. The final swf will have loads of graphics and this will probably take some time.

And second, not all text fields are in the first frame. So, if I followed this way I would have to redo all the iteration every frame and even then the fields would probably flicker because of the font change.

What I’m asking is: how do I tell my text fields to use the font that will be loaded in the future, so they make the change as soon as they appear? Or better yet, how do I set a “default” font for all text fields without referencing them individually?