带参数的函数call()

Seb*_*ler 1 apache-flex components function actionscript-3

我有一个组件,我交给一个函数

public var func : Function;
Run Code Online (Sandbox Code Playgroud)

现在该函数是一个在其签名中包含参数的函数

public function myFunction(s : String) : void {
   doSomething(s);
}
Run Code Online (Sandbox Code Playgroud)

从我的组件我可以调用该函数

func.call();
Run Code Online (Sandbox Code Playgroud)

有人能告诉我如何用它的参数调用函数吗?

Jam*_*ard 6

你应该能够做到这一点:

func("foo");
Run Code Online (Sandbox Code Playgroud)

要么

func.call(this, "foo");
Run Code Online (Sandbox Code Playgroud)

要么

func.apply(this, ["foo"]);
Run Code Online (Sandbox Code Playgroud)

查看AS3文档中Function对象的文档.