Adobe FLEX 2-PROGRAMMING ACTIONSCRIPT 3.0 Manual page 136

Programming actionscript 3.0
Table of Contents

Advertisement

package
{
import flash.display.MovieClip;
public class OverrideExample extends MovieClip
{
public function OverrideExample()
{
trace(currentLabel)
}
override public function get currentLabel():String
{
var str:String = "Override: ";
str += super.currentLabel;
return str;
}
}
}
The output of the
trace()
, which shows that the example was able to override the inherited
null
property.
Static properties not inherited
Static properties are not inherited by subclasses. This means that static properties cannot be
accessed through an instance of a subclass. A static property can be accessed only through the
class object on which it is defined. For example, the following code defines a base class named
Base and a subclass that extends Base named Extender. A static variable named
in the Base class. The code as written in the following excerpt does not compile in strict mode
and generates a run-time error in standard mode.
package {
import flash.display.MovieClip;
public class StaticExample extends MovieClip
{
public function StaticExample()
{
var myExt:Extender = new Extender();
trace(myExt.test);
}
}
}
class Base {
public static var test:String = "static";
}
class Extender extends Base { }
136
Object-Oriented Programming in ActionScript
statement in the OverrideExample class constructor is
// error
Override:
currentLabel
is defined
test

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex

Table of Contents