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
.
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
.
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.
Yes it is possible to use MovieClip names like _myclip, you can reference it statically this._myclip
or dynamically too. this["_"+"myclip"]
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.
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:
private var _word:String = "something"
public function get word():String {
return _word
}
public function set word(a_word:String):void {
_word = a_word
}
A little verbose, but it makes for a nice API.