是否可以使用“获取”和“设置” AS3 中的匿名函数?

发布于 2024-10-01 19:25:14 字数 245 浏览 1 评论 0原文

我已经尝试过了,但也许语法是错误的:

course.totalScore = function get():int
{
...
}

我得到“1084:语法错误:在 get 之前期望 leftparen”。

我的印象是这个关键字只适合在类中使用,即它不适用于 AS3 的底层原型性质。

注意给出的示例是在类方法中,而不是在时间线框架脚本中,所以请不要引用我的 livedocs。

I've tried it, but perhaps the syntax is wrong:

course.totalScore = function get():int
{
...
}

I get "1084: Syntax error: expecting leftparen before get."

My impression is that this keyword is meant for use in classes only, i.e. it doesn't apply to AS3's underlying prototypal nature.

NOTE The example given is within a class method, NOT in a timeline frame script, so don't quote me livedocs please.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夏末染殇 2024-10-08 19:25:14

getset 函数仅适用于类,因为它们旨在补充类的属性。脱离了这种背景就没有多大意义。

The get and set functions only work on a class because they are meant to supplement the properties of a class. The don't make much sense outside of that context.

缘字诀 2024-10-08 19:25:14

是的,不幸的是,获取、设置和属性只能在类中使用......

Yes, unfortunately, get, set and properties will only work in classes...

憧憬巴黎街头的黎明 2024-10-08 19:25:14

尝试

course.totalScore = function ():int
{
...
}

try

course.totalScore = function ():int
{
...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文