inheriting statics

zwetan zwetan at gmail.com
Sun Jan 7 11:10:37 PST 2007


On 1/7/07, Peter Hall <peterjoel at gmail.com> wrote:
> "Since inheritance does not apply to static members"
>
> Your assumption is what I was questioning. Why doesn't inheritance
> apply to static members?
>
>

statics are defined on the class itself not the instances of this class
so when you inheriting you can not access static members trough
the instance, only throught the class

but within your classes definition, you can access static members
trough the scope chain


all is pretty well explained in the Flex2 doc

Programming ActionScript 3.0 / Object-Oriented Programming in
ActionScript / Inheritance
then look at the examples for
Static properties not inherited
and
Static properties and the scope chain


I know only one special case where a static member is used for inheritance,
it's the static var prototype :)

quoting the doc
"...
This property is static in that it is specific to the class or
function that you create. For example, if you create a class, the
value of the prototype property is shared by all instances of the
class and is accessible only as a class property. Instances of your
class cannot directly access the prototype property.
"


cheers,
zwetan



More information about the Es4-discuss mailing list