Archive for October, 2008

Static methods 101 in AS3 revisit

October 31, 2008


1. Inheritance (of a member method) means the derived class keeps a copy of the base class member method. Static methods are not inherited and cannot be overridden. To override a method means to redefine the behavior of an inherited method.

2. Keywords “private”, “protected”, “internal” are used to control scope/accessibility of the members as to other classes (i.e., if the code can be used by others).

In AS3, private members are only visible to the class itself, and NOT to the subclasses. If you want to use (call a method or refer to a property) members from a superclass, you need to mark them as “protected”.

In AS3, protected members are visible to the class and all subclasses. Internal members are visible to all classes within the same package.

3. Override. When you “override” a class method, you “specify that a method replaces an inherited method”. This means the “overridden” method will be invoked in place of the inherited method, even if you just define the signature of the method (i.e., a null method, like so

override protected function myfoo():void{}

Overriding variables is not permitted. To override a property means to redefine the property in a subclass.

4. It’s permissible to define an instance property using the same name as a static property within a class.


Using the Repeater component

October 27, 2008