In ActionScript (AS3) how do I find all the classes that implement a particular interface?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
In OOP terms, you never want to be able to do this: the primary characteristic of interfaces is they are terms of a contract. Any class can choose to fulfill that contract and be able to say "I implement this interface".
Any code that references an instance of the interface don't care what class actually implements it: they don't have to; that's the really cool part of interfaces.
But if you want to find out, grep for "implements IFred"
Cheers
回答2:
I've figured out how to do this and posted a demo on my blog. It uses the getDefinitionNames library mentioned in the comments above.
回答3:
In Flash Builder I use ctrl-h and search for method names or the actual name of the interface.