是“_”吗? 为影片剪辑名称保留前缀?
是否可以使用“_”下划线前缀作为您自己的MovieClip名称?(AS2)
即您可以将创建/附加的MovieClip命名为“_feature”或“_bug” ?
通常,这是为内部属性保留的,例如_x
或_visible
。
Is it possible to use the "_" underscore prefix for your own MovieClip names? (AS2)
i.e. Can you name a created/attached MovieClip "_feature" or "_bug" ?
Typically this is reserved for internal properties like _x
or _visible
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
“_”前缀没有技术意义 - 您可以将其用作影片剪辑、文本字段或任何其他您喜欢的变量或方法的名称。
作为一种约定,“内置”属性的名称(如
_x
、_visible
等)过去很常见以下划线开头,但它们停止了在 v6 或 v7 周围执行此操作,因此许多后续属性(例如filters
、transform
)不使用它。 此外,他们还使用(我相信在 AS3 中仍然使用)多个下划线来表示他们不希望人们被绊倒的内部名称(例如__proto__
)。过去还有一个相当广泛的约定,即在要私有的属性或方法前面添加
$
,因为将它们声明为私有没有任何效果。 您在组件中经常看到这种情况。The "_" prefix has no technical significance - you can use it your own names for MovieClips, text fields, or any other variable or method you like.
As a convention, it used to be common for the names of "built in" properties (like
_x
,_visible
, etc.) to begin with an underbar, but they stopped doing this around v6 or v7, so many later properties (filters
,transform
for example) don't use it. Also, they've used (and still use I believe, in AS3) multiple underbars for internal names they don't want people to trip over (like__proto__
).There also used to be a fairly widespread convention to prepend
$
to properties or methods intended to be private, since declaring them to be private doesn't have any effect. You see this a lot in components.是的,这很好。 不太确定你应该这样做,但如果你有这样的情况,它就不会出错。 我倾向于保留 _ 作为类的私有成员的前缀。
Yes this is fine. Not really sure you should be doing it but if you have a case for it it won't error out. I tend to reserve _ to prefix private members of a class.
是的,可以使用像_myclip这样的MovieClip名称,您可以静态
this._myclip
或动态引用它。这个["_"+"myclip"]
Yes it is possible to use MovieClip names like _myclip, you can reference it statically
this._myclip
or dynamically too.this["_"+"myclip"]
这很好,但正确的 as3 做法是仅将“”用于内部、私有/受保护的变量,然后编写不带“”的 getter 和 setter。
例如:
有点冗长,但它是一个很好的 API。
It is fine, but proper as3 practice is to use the "" for only internal, private/protected variables, and then write getters and setters without the "".
eg:
A little verbose, but it makes for a nice API.