Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 114

Programming actionscript 3.0
Table of Contents

Advertisement

Static properties are not inherited by subclasses, but the properties are part of a subclass's
scope chain. This means that within the body of a subclass, a static variable or method can be
used without referencing the class in which it was defined. For more information, see
properties not inherited" on page
User-defined namespace attributes
As an alternative to the predefined access control attributes, you can create a custom
namespace for use as an attribute. Only one namespace attribute can be used per definition,
and you cannot use a namespace attribute in combination with any of the access control
attributes (
,
public
private
namespaces, see
"Namespaces" on page
Variables
Variables can be declared with either the
keyword can have their values changed multiple times throughout the execution of a
var
script. Variables declared with the
assigned to them only once. An attempt to assign a new value to an initialized constant results
in an error. For more information, see
Static variables
Static variables are declared using a combination of the
and
statements. Static variables, which are attached to a class rather than an instance of
const
a class, are useful for storing and sharing information that applies to an entire class of objects.
For example, a static variable is appropriate if you want to keep a tally of the number of times
a class is instantiated or if you want to store the maximum number of class instances that are
allowed.
The following example creates a
instantiations and a
MAX_NUM
and
totalCount
MAX_NUM
class as a whole rather than to a particular instance.
class StaticVars
{
public static var totalCount:int = 0;
public static const MAX_NUM:uint = 16;
}
114
Object-Oriented Programming in ActionScript
136.
,
,
protected
internal
43.
or
var
keyword are called constants, and can have values
const
"Constants" on page
variable to track the number of class
totalCount
constant to store the maximum number of instantiations. The
variables are static because they contain values that apply to the
). For more information about using
keywords. Variables declared with the
const
76.
keyword and either the
static
"Static
var

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents