在Flex 4中有没有办法获取域中的所有类?
有没有办法获取当前应用程序中的所有类。举例来说,您创建一个空白应用程序并希望查看存在的所有类,这将列出系统管理器、应用程序、ui组件等。
Is there a way to get all the classes in the current application. Say for example you create a blank Application and want to see all the classes that exist, this would list system manager, application, uicomponent, etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,标准反射 API 不提供域中的类列表。
但是,存在 AS3 Commons Bytecode 库,它能够读取当前应用程序的字节码(或与此相关的任何字节码)并解析它,提供对域中所有当前类的访问。 (以及一大堆其他很酷的东西)。
此处有一个示例,展示了如何执行您的操作。
使用这个库的缺点是你必须在运行时重新加载和解析数据,这会带来很大的性能成本。
James Ward 和 Mike Labriola 做了一些修改 SWF 加载器的工作,这些加载器将初始字节码加载到 Flex 应用程序中,以便在启动时执行反射,从而减少两次解析字节码的需要。
James 在此处< /a>.
Unfortunately, the list of classes in the domain is not made available by the standard Reflection API.
However, the AS3 Commons Bytecode library exists, which is able to read the Bytecode of the current app (or any bytecode for that matter) and parse it, providing access to all the current classes in the domain. (Along with a whole bunch of other cool stuff).
There's an example showing how to do what you're after here.
The downside of using this library is that you have to re-load and parse the data at runtime, which has a significant performance cost.
James Ward and Mike Labriola did some work on modifying the SWF Loaders which load the initial bytecode into your flex app, so that the reflection is performed at startup, reducing the need to parse the bytecode twice.
James has blogged about his results here.