How to monkey patch or override a swc class in Flex?

2k views Asked by At

I'm using a swc from the Axiis project to display visualizations in a project I'm working on. I've run into a bug where re-compiling the library swc would be an easy solution, but I can only use the buggy version of the swc.

I have the Axiis source and compiled a version with the bug fixed, though I'm not allowed to use it because of client version restrictions.

Does anyone know how I can use the updated Actionscript class/file in my code so it overrides the swc class?

1

There are 1 answers

4
Christophe Herreman On BEST ANSWER

I'm not sure if you are allowed to do the following: put the class with your fix in the source path of your main application. If you make sure the package and class names match exactly with the original class, the compiler will pick this class up instead of the one in the library. We do this often when we want to patch the Flex framework without having to compile the libraries ourselves.

Another idea might be to use AS3Commons-Bytecode to create a proxy of the class you want to fix and then have your code work on the proxy instead of the original instance. This is a pure runtime fix. It's a bit more advanced and it will only work if you can somehow get the proxy to replace the original instance of the class you need to fix.