ActionScript 3 Language Specification |
|||
| ActionScript 3.0 Language Specification > 9 Classes > 9.5 Class variables | |||
Class variables are defined using the var or const keywords.
class A
{
var x
const k = 10
}
The meaning of var and const follow from the general meaning described in the sections 7 Variables and 1.4 Variables.
|
var |
May be written to multiple times |
|
const |
May be written to only once |
const variable properties can be written to only once. The compiler uses a specific data flow analysis to determine if a const variable has been written to at the point of an assignment to that variable. Informally, the effect of this algorithm can be seen in the following error cases:
const instance or static variable in a statement that is outside of the instance or static initializer, respectively.const variable more than once in a sequence of statements with no control flow branches.const variable in more than one parallel control flow branch if the branch conditions are not compile-time constant expressions, or if the value of those branch conditions allow for one or more of those branches to be executed more than once.The default value of a class or instance variable is the value of undefined coerced to the type of the variable.
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/specs/actionscript/3/as3_specification85.html