
Classes and packages 27
Using classes
This section describes changes to ActionScript classes.
Access modifiers
The new internal access modifier refers to a different namespace in each package definition,
and is not defined outside of a package definition (that is, in global code).
If a class in a package isn’t marked
public or private, then it defaults to internal. The class
cannot be accessed by classes in other packages; this is the same as the
protected modifier in
Java. Accessing internal classes from outside of the package causes a ReferenceError at run
time.
If you do not put any namespace (public, private, internal, or user-defined) on a declaration,
the Flex compiler throws a warning.
The following table summarizes the access modifiers:
Inside a package, the default access specifier is
internal. Outside of a package, the default
access specifier is
public.
Class identifiers
The form ClassIdentifiers:ClassIdentifiers.Identifier has been deprecated and results in a
compile-time warning. It is equivalent to declaring the class name Identifier in the package
ClassIdentifiers. For example:
class P.A {} // ActionScript 2.0
package P { // ActionScript 3.0
class A {}
}
super()
You can only use a super() statement inside a constructor. It is a syntax error to use a
super() statement anywhere else in a program. Previous versions of ActionScript allowed
super() statements to be used anywhere in a class (except in a static method).
Access Modifier Description
private Only accessible to the class.
public Accessible from anywhere.
protected Private to classes and subclasses.
internal Private to other classes in the package.
Commenti su questo manuale