User Guide

Classes 111
}
// In your script
var myST:StaticTest = new StaticTest();
trace(StaticTest.message); // static variable
trace(myST.message); // instance variable
Class property attributes
In discussions of the ActionScript object model, the term property means anything that can be
a member of a class, including variables, constants, and methods. This differs from the way
the term is used in the ActionScript 3.0 Language Reference, where the term is used more
narrowly and includes only class members that are variables or are defined by a getter or setter
method. In ActionScript 3.0, there is a set of attributes that can be used with any property of
a class. The following table lists this set of attributes.
Access control namespace attributes
ActionScript 3.0 provides four special attributes that control access to properties defined
inside a class:
public, private, protected, and internal.
The
public attribute makes a property visible anywhere in your script. For example, to make
a method available to code outside its package, you must declare the method with the
public
attribute. This is true for any property, whether it is declared using the
var, const, or
function keywords.
The
private attribute makes a property visible only to callers within the propertys defining
class. This behavior differs from that of the
private attribute in ActionScript 2.0, which
allowed a subclass to access a private property in a superclass. Another significant change in
behavior has to do with run-time access. In ActionScript 2.0, the
private keyword
prohibited access only at compile time, and was easily circumvented at run time. In
ActionScript 3.0, this is no longer true. Properties that are marked as
private are unavailable
at both compile time and run time.
Attribute Definition
internal (default) Visible to references inside the same package.
private
Visible to references in the same class.
protected
Visible to references in the same class and derived classes.
public
Visible to references everywhere.
static
Specifies that a property belongs to the class, as opposed to
instances of the class.
UserDefinedNamespace
Custom namespace name defined by user.