flashactionscriptfontsrsl

How do I make sure a RSL in Flash/Flex, is loaded prior to instantiating a class that uses a shared library asset?


The issue I'm encountering is if I immediately instantiate an asset loaded that requires an asset from a RSL, sometimes the RSL has not initialized yet, and null is returned for the Font Class ArialRegular. Other times I get a "Reference Error".

How might I check for the proper initialization of an RSL and loaded assets? Checking for a null class works sometimes for when the accessed class itself returns null, but when there is instead a Reference Error checking for Null won't help.

I've used RSL for better or worse for many years so I have extensive experience with it. The problem I'm encountering seems specific to Fonts.

Solution: I answered my question below.


Solution

  • OK, I've found a solution that points to a cause that cannot be corrected but can be avoided.

    Basically if you have TextFields (classic, or TLF) that use the fonts you have embedded via a RSL they need to be dynamically created at run time. They cannot be a part of the original SWF asset that was loaded. Static text is OK, but dynamic and input text that requires an RSL asset messes up, unless it is dynamically generated after the Font asset has been loaded.

    This is one of those subtle issues that I have figured out in the past, and wish I hadn't forgotten about.