外部接口错误
这是我用来在 javascript 中调用函数 calc
的代码:
import flash.external.ExternalInterface;
ExternalInterface.addCallback("asFunc", this, asFunc);
function asFunc(str:String):Void {
out.text = "JS > Hello " + str;
}
send_btn.addEventListener(MouseEvent.CLICK, clickListener);
function clickListener(eventObj:Object):Void {
trace("click > " + mean.text);
ExternalInterface.call("calc", mean.text);
}
但出现以下错误:
1046:未找到类型或不是编译时常量:Void。
我在这里做错了什么? (我修改了实时文档中的示例。)
This is the code I am using to call a function calc
in javascript:
import flash.external.ExternalInterface;
ExternalInterface.addCallback("asFunc", this, asFunc);
function asFunc(str:String):Void {
out.text = "JS > Hello " + str;
}
send_btn.addEventListener(MouseEvent.CLICK, clickListener);
function clickListener(eventObj:Object):Void {
trace("click > " + mean.text);
ExternalInterface.call("calc", mean.text);
}
but I get the following error:
1046: Type was not found or was not a compile-time constant: Void.
What am I doing wrong here? (I modified the example on live docs.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
void 应该是小写。
像这样:
Void should be lower-case.
Like this:
看起来(根据你的错误)你在这里有几个问题:
所以假设你的JavaScript代码是这样的:
...你相应的ActionScript 3 代码应该看起来更像这样:
有意义吗?
Looks (by your error) like you have a couple of problems here:
So assuming your JavaScript code were something like this:
... your corresponding ActionScript 3 code should look something more like this:
Make sense?