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

烈酒焚心 提交于 2019-12-20 07:06:10

问题


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:


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.



来源:https://stackoverflow.com/questions/5096795/how-to-monkey-patch-or-override-a-swc-class-in-flex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!