我有一个加载模块的应用程序。这些模块可以由第三方开发。因此,为了让他们更容易,我想开发一个API,让他们知道可以调用和使用哪些函数。
所以我知道这可以在一个模块中工作,但是你必须知道在parentApplication中有一个变量“费用”:
// Access properties of the parent application.
private function getDataFromParent():void {
expenses = parentApplication.expenses;
} 但我更喜欢这样的东西:
private function getDataFromParent():void {
var myParent : MyAPI = new MyAPI();
expenses = myParent.getExpenses();
} 所以,如果它是这样工作的,当您开始编码并输入“myParent”时。Flex将建议所有可能的函数和变量,并提供代码提示。
你有什么办法开始做这个吗?
非常感谢,
弗兰克
发布于 2011-08-08 22:22:06
我会为"parent“创建一个接口,并为"modules”创建一个接口。这让您能够以相同的方式处理所有模块,并使各个模块开发人员很容易知道“父模块”提供了什么。
public class IModule {
// when initialize() is called it will be up to the module's developer to
// retain a reference to the parent and use that for later calls
function initialize(parent:IParent):void;
function doStuff():Boolean;
}
public class IParent {
function getInfo():String;
function foo(value:int):int;
}https://stackoverflow.com/questions/6983059
复制相似问题