如何在 Flex 中修补或覆盖 swc 类? [英] How to monkey patch or override a swc class in Flex?

查看:31
本文介绍了如何在 Flex 中修补或覆盖 swc 类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Axiis 项目中的 swc 来显示我正在处理的项目中的可视化.我遇到了一个错误,重新编译库 swc 是一个简单的解决方案,但我只能使用有问题的 swc 版本.

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.

我有 Axiis 源并编译了一个修复了错误的版本,但由于客户端版本限制我不允许使用它.

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.

有谁知道如何在我的代码中使用更新的 Actionscript 类/文件以覆盖 swc 类?

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

推荐答案

我不确定是否允许您执行以下操作:将带有修复程序的类放在主应用程序的源路径中.如果您确保包名和类名与原始类完全匹配,编译器将选择此类而不是库中的类.当我们想要修补 Flex 框架而不必自己编译库时,我们经常这样做.

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.

另一个想法可能是使用 AS3Commons-Bytecode 创建一个您要修复的类的代理,然后让您的代码在代理上而不是原始实例上工作.这是一个纯粹的运行时修复.它更高级一些,并且只有在您能够以某种方式让代理替换您需要修复的类的原始实例时,它才会起作用.

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.

这篇关于如何在 Flex 中修补或覆盖 swc 类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆