As the title says, is there a way to alter the ResourceManager’s getStringArray() in a way that it splits the resources by semicolon, not comma?
The actual method can be found in the ResourceManagerImpl class, which can be found in in the package mx.resources.
Overriding that method would be fine, but ideally I’d like to write my own getStringArray with a variable separator, however, there seems to be no way of extending either the ResourceManager or ResourceManagerImpl class to somehow add that method.
Anyone got a clue what to do here?
The problem is not that you can’t extend
ResourceManagerImplsince it’s notfinal, but rather that you have to be able to register your implementation with the application instead of the default one. And doing this is a bit tricky.So first create your implementation:
So we’ve overriden the
getStringArraymethod. Notice that we’ve done the same forgetInstance, because we want it to return a new instance ofMyResourceManagerinstead ofResourceManagerImpl(we don’t have to markoverridebecause it’s astaticmethod). Also, you may have to write some import statements manually, because some of the classes you’re using are marked as ‘excluded’.Now we have to tell Flex to use
MyResourceManagerinstead ofResourceManagerImpl. We can do this with the following code:The problem is that we have to do this before Flex registers
ResourceManagerImpl, because you can’t override it once it’s registered. For this we need to create a custom preloader in which we do the registering (sadly, the Application’s ‘preinitialize’ phase is not early enough).Now assign the custom preloader to the application and we’re done:
For further info I refer you to a fairly similar, but somewhat more elaborate answer that I wrote for a different question: Is there a way to listen for events on the pop up manager class?