User Guide

132 Object-Oriented Programming in ActionScript
...
}
Other types of events require unique properties not available in the Event class. These events
are defined using subclasses of the Event class so that new properties can be added to the
properties defined in the Event class. An example of such a subclass is the MouseEvent class,
which adds properties unique to events associated with mouse movement or mouse clicks,
such as the
mouseMove and click events. The following example is an excerpt from the
MouseEvent class that shows the definition of properties that exist on the subclass, but not on
the base class:
public class MouseEvent extends Event
{
public static const CLICK:String = "click";
public static const MOUSE_MOVE:String = "mouseMove";
...
public function get stageX():Number {}
public function get stageY():Number {}
...
}
Access control specifiers and inheritance
If a property is declared with the public keyword, the property is visible to code anywhere.
This means that the
public keyword, unlike the private, protected, and internal
keywords, places no restrictions on property inheritance.
If a property is declared with
private keyword, it is visible only in the class that defines it,
which means that it is not inherited by any subclasses. This behavior is different from previous
versions of ActionScript, where the
private keyword behaved more like the ActionScript 3.0
protected keyword.
The
protected keyword indicates that a property is visible not only within the class that
defines it, but also to all subclasses. Unlike the
protected keyword in the Java programming
language, the
protected keyword in ActionScript 3.0 does not make a property visible to all
other classes in the same package. In ActionScript 3.0, only subclasses can access a property
declared with the
protected keyword. Moreover, a protected property is visible to a subclass
whether the subclass is in the same package as the base class or in a different package.
To limit the visibility of a property to the package in which it is defined, use the
internal
keyword or do not use any access control specifier. The
internal access control specifier is
the default access control specifier that applies when one is not specified. A property marked
as
internal will be inherited only by a subclass that resides in the same package.