gpt4 book ai didi

actionscript - $(var) 在 Actionscript 中是什么意思?

转载 作者:行者123 更新时间:2023-12-04 05:12:06 24 4
gpt4 key购买 nike

我经常在正在查看的 Actionscript 代码中看到 $(var),其中 var 是先前定义的变量。这到底是什么意思?

最佳答案

编辑:感谢joshtynjalas的指正,下面这行写错了,抱歉!美元符号实际上可以像在 JS 中一样使用(见底部示例):

Actionscript 中,您不能单独使用 $ 符号作为属性名称(至少在 AS2 和 AS3 中)。

虽然它可以与其他角色结合使用。碰巧开发人员使用它作为前缀来标识静态字段或常量(例如 private static var $boxHeight:int = 480 )。

仅供引用,这是 ECMA 脚本规范中的一句话:

"This standard specifies one departure from the grammar given in the Unicode standard: The dollar sign ($) and the underscore (_) are permitted anywhere in an identifier. The dollar sign is intended for use only in mechanically generated code."

我猜你把它和 Javascript 混淆了,美元符号可以被认为是变量名。因此,您可以将其分配为预定义函数的快捷方式引用。

function popup(value)
{
alert(value)
}

$ = popup;

$("hello");
$("world");

这种做法被 Prototype(.js) 广泛引入,以抽象出相当痛苦的 getElementById(id_name);

关于actionscript - $(var) 在 Actionscript 中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/588365/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com